How to assign a variable in a workflow if InvokeMethod activity returns an object? - c#-6.0

I have an InvokeMethod Activity in Windows Workflow Foundation. This workflow is quite simple:
ask to user for his/her height
if height is greater than 5.9, then ask his/her profile details
display profile details
To achieve this, I have created a workflow, seen below:
How can I assign an object which is return from InvokeMethod as variable?
I have posted my code on GitHub.

Here is the solution within Visual Studio properties:
First add a variable to your workflow:
Drop an InvokeMethod Activity into your workflow workspace and
edit properties:
MethodName: Enter your MethodName
Parameters: Set parameters (Direction: In, Type: typeNeeded, Value yourValue)
Result: Enter the variable name from your workflow defined earlier
TargetType: Set the type of your method return's type
Here is the solution in XAMLX
xmlns:mca="clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities"
xmlns:p1="http://schemas.microsoft.com/netfx/2009/xaml/activities"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
<p1:InvokeMethod sap2010:WorkflowViewState.IdRef="InvokeMethod_1" MethodName="YourMethodName" TargetType="x:Object">
<p1:InvokeMethod.Result>
<p1:OutArgument x:TypeArguments="x:Object">
<mca:CSharpReference x:TypeArguments="x:Object">workflowVariableName</mca:CSharpReference>
</p1:OutArgument>
</p1:InvokeMethod.Result>
<p1:InArgument x:TypeArguments="x:Int32">
<mca:CSharpValue x:TypeArguments="x:Int32">variableNamePassedToMyMethod;</mca:CSharpValue>
</p1:InArgument>
</p1:InvokeMethod>

Related

how to I override the value of APP_VERSION substitution string in Oracle APEX

In my apex application I want to display custom application version. From the page template I see that it is using substution string APP_VERSION.
I tried changing this in application properties > Difinition > Substitution String. But it is not reflecting the changes.
Can anyone suggest how to solve this problem ?
The APP_VERSION is a substitution string. It cannot be overridden by a user defined substitution string. It takes the value from application properties > Definition > Name: Version.
This substitution string can be used in file url definition and as a template substitution string. It cannot be used in apps using the &P_ITEM. syntax and is not available in pl/sql as a bind variable.
I was able to solve this problem by adding application level item APP_VERSION. Added this as &APP_VERSION at field application properties > Definition > Name: Version.
In an Application Process, application level item APP_VERSION is assigned a value after reading a property in database table.

Behavior of assigning instance variable to persistent data that factory girl creates

I have seen this kind of notation elsewhere: #user = FactoryGirl.create(:user), but can't figure out exactly how this instance variable will behave.
Specifically, I'm wondering about the behavior of this instance variable. For example, I'm currently creating integration tests in RSpec. In one of the tests, I tried to assign an instance variable to an instance of my Video class:
#video = FactoryGirl.create(:video, title: "Test title")
I have no trouble at that point accessing the different attributes of the video instance (e.g., using #video.title)).
However, I am creating an integration test to make sure that a user can clear the "title" field in the form and when the video updates, the title is erased in the database. E.g.,
click_link "Edit"
fill_in "Title", with: ""
click_button "Update Video"
expect(find('#title')).to_not have_content "Test title"
For some reason, the page displays correctly, but when I try to access the instance using the instance variable, no change has occurred: print #video.title returns "Test title"
What is strange is that in a different integration test I use a similar process to update the video instance's attributes (e.g., to "Updated Test title"). I then tested to see if the attributes updated correctly in the webpage, and they did, but this time instance variable also reflected that (using print #video.title).
Any guesses on why this would be the case?
The solution is to use #video.reload.title, to update record from DB.
When you create #video it is now disconnected from the database changes (static copy in a Video object) reload will cause it to refresh itself from the database showing the changes made since its initial assignment.
Resources include:
binarapps.com/blog/rspec-reload-objects
everydayrails.com/2015/04/05/rspec-assigns-rails-testing.htm‌​l
http://spaghettirefactory.blogspot.com/2015/01/reload-stale-objects-in-finnicky-rails.html
(Credit goes to #SergiiK and #engineersmnky who answered the question in the above comments.)

HP-UFT object not found in object repository error

Getting the following error while executing script:
WebList object was not found in the Object Repository.
Check the Object Repository to confirm that the object exists or to find the correct name for the object.
Line (1221): "objParent.WebList(vstrObjectName).select vstrValue".
I understand, it shouldn't be as simple as the object isn't available in the repository but in in case- Try to use 'Locate in repository'
It looks like Line (1221) is trying to access a WebList object by name, but the name is stored in a variable; it is not a string literal in the code.
There might be 3 different things going on here.
1) if you were attempting to use Descriptive Programming, then it sounds like the contents of vstrObjectName didn't include the ":=" symbol that would make QTP believe the string is a description... So, QTP thinks the string stored in vstrObjectName must be the name of an object in the Object Repository.
I would like to guess that you were trying to use descriptive programming, since (based on the fact that the parent, and the parameter are also both contained in variables) it looks like you are avoiding using any string literals in that line.
2) If you were attempting to control an object with a name from the Object repository, then either the string contained in vstrObjectName didn't contain a valid object name (that belongs to objParent), or
3) the object refered to by objParent isn't the one you were expecting.
In any of these cases, if it were me, the first thing I would do is add a print statement before line 1221 as:
Print "vstrObjectName:'" & vstrObjectName & "'"
...and run it again. That should show the string that you were referencing. I would guess that the resulting output line is not what you expected.
Another thing to check is to make sure that the action or function that contains that line is executed from within an action that contains that named object in it's OR scope. (i.e. open the action and hit CTRL-R, it shows the combined OR that is visible to that action). If the line is in a function library, and it gets called from an action that doesn't have the object in it's local OR, or an attached shared OR, then you will get the same error. This kind of problem is very easy to cause if you use multiple actions, and the action containing the call to the function that contains your line (line 1221) doesn't actually have that object available to it due to it's OR scope.
To answer the question you asked - how to add object into the OR - you could use several methods - recording, guispy's add to OR button, manually add from the OR screen, etc... but in the end, you need that object in the OR to have a name that matches whatever is in vstrObjectName.
Some potential examples where an object can be selected:
Dynamically change the object based on the name of the object in the object repository:(must exist in the repository)
Dim objectname
objectname = "SAP Work Manager"
msgbox WpfWindow(objectname).Exist
Select an object that does not exist in the Object repository, by its properties:
WpfWindow("text:=SAPWorkManager").Exist
Example page of UFT tips

AX2012 - Pre-Processed RecId parameter not found

I made a custom report in AX2012, to replace the WHS Shipping pick list. The custom report is RDP based. I have no trouble running it directly (with the parameters dialog), but when I try to use the controller (WHSPickListShippingController), I get an error saying "Pre-Processed RecId not found. Cannot process report. Indicates a development error."
The error is because in the class SrsReportProviderQueryBuilder (setArgs method), the map variable reportProviderParameters is empty. I have no idea why that is. The code in my Data provider runs okay. Here is my code for running the report :
WHSWorkId id = 'LAM-000052';
WHSPickListShippingController controller;
Args args;
WHSShipmentTable whsShipmentTable;
WHSWorkTable whsWorkTable;
clWHSPickListShippingContract contract; //My custom RDP Contract
whsShipmentTable = WHSShipmentTable::find(whsWorkTable.ShipmentId);
args = new Args(ssrsReportStr(WHSPickListShipping, Report));
args.record(whsShipmentTable);
args.parm(whsShipmentTable.LoadId);
contract = new clWHSPickListShippingContract();
controller = new WHSPickListShippingController();
controller.parmReportName(ssrsReportStr(WHSPickListShipping, Report));
controller.parmShowDialog(false);
controller.parmLoadFromSysLastValue(false);
controller.parmReportContract().parmRdpContract(contract);
controller.parmReportContract().parmRdpName(classStr(clWHSPickListShippingDP));
controller.parmReportContract().parmRdlContract().parmLanguageId(CompanyInfo::languageId());
controller.parmArgs(args);
controller.startOperation();
I don't know if I'm clear enough... But I've been looking for a fix for hours without success, so I thought I'd ask here. Is there a reason why this variable (which comes from the method parameter AifQueryBuilderArgs) would be empty?
I'm thinking your issue is with these lines (try removing):
controller.parmReportContract().parmRdpContract(contract);
controller.parmReportContract().parmRdpName(classStr(clWHSPickListShippingDP));
controller.parmReportContract().parmRdlContract().parmLanguageId(CompanyInfo::languageId());
The style I'd expect to see with your contract would be like this:
controller = new WHSPickListShippingController();
contract = controller.getDataContractObject();
contract.parmWhatever('ParametersHere');
controller.parmArgs(args);
And for the DataProvider clWHSPickListShippingDP, usually if a report is using a DataProvider, you don't manually set it, but the DP extends SRSReportDataProviderBase and has an attribute SRSReportParameterAttribute(...) decorating the class declaration in this style:
[SRSReportParameterAttribute(classstr(MyCustomContract))]
class MyCustomDP extends SRSReportDataProviderBase
{
// Vars
}
You are using controller.parmReportContract().parmRdpContract(contract); wrong, as this is more for run-time modifications. It's typically used for accessing the contract for preRunModifyContract overloads.
Build your CrossReference in a development environment then right click on \Classes\SrsReportDataContract\parmRdpContract and click Add-Ins>Cross-reference>Used By to see how that is generally used.
Ok, so now I feel very stupid for spending so much time on that error, when it's such a tiny thing...
The erronous line is that one :
controller.parmReportName(ssrsReportStr(WHSPickListShipping, Report));
Because WHSPickListShipping is the name of the AX report, but I renamed my custom report clWHSPickListShipping. What confused me was that my DataProvider class was executing as wanted.

CustomActionData does not seem to be populated or accessable by my vbscript

Ok, this is driving me crazy.
I have a CA that needs to know the path of the INSTALLDIR to edit an XML file.
So, I set up a set property custom action that sets a property named RemoveAuthTypesNode to [INSTALLDIR]. Then I have a RemoveAuthTypesNode CA that is sequenced after SetConfigFolder (a set property that sets installdir to a system searched path) in the Install Execute Sequence, Deferred in System Context (doesn't work when just Deferred Exec either).
In the log I see that RemoveAuthTypesNode is set:
MSI (c) (D4:EC) [16:12:05:314]:
PROPERTY CHANGE: Adding
RemoveAuthTypesNode property. Its
value is 'C:\Program Files\Microsoft
SQL
Server\MSRS10.MSSQLSERVER\Reporting
Services\ReportServer\'.
The custom action errors:
Error 1720.There is a problem with
this Windows Installer package. A
script required for this install to
complete could not be run. Contact
your support personnel or package
vendor. Custom action
RemoveAuthTypesNode script error
-2146827864, Microsoft VBScript runtime error: Object required:
'objXMLDOMNode' Line 9, Column 1, MSI
(s) (78:EC) [16:12:23:916]: Product:
ASMI User Defined Reports -- Error
1720.There is a problem with this Windows Installer package. A script
required for this install to complete
could not be run. Contact your support
personnel or package vendor. Custom
action RemoveAuthTypesNode script
error -2146827864, Microsoft VBScript
runtime error: Object required:
'objXMLDOMNode' Line 9, Column 1,
This is failing because the path isn't correct so the XMLDom object never loads. I know this because if I hardcode the path everything works fine.
Also, when I search the log for CustomActionData I expected that it would be in there as being set.
Here is the code from the custom action. The msgbox is just for debugging. It is always displaying nothing.
strConfigFile = session.Property("CustomActionData") & "rsreportserver.config"
MsgBox session.Property("CustomActionData")
Set xDoc = CreateObject("Microsoft.XMLDOM")
xDoc.async = False
xDoc.Load(strConfigFile)
set objXMLDOMNode = xDoc.selectSingleNode("//Configuration/Authentication/AuthenticationTypes")
set objParentNode = objXMLDOMNode.parentNode
objParentNode.removeChild(objXMLDOMNode)
xDoc.save(strConfigFile)
Set xDoc = Nothing
What am I doing wrong? I'm sure it's something simple stupid. Help greatly appreciated.
The custom action that sets the property named for the vbscript custom action was setting a private property (not all upper case). So, the set property custom action had to be sequenced in the Execute sequence rather than the UI sequence. Once I made this change the correct data was being retrieved in the script.
It is expected if I have made a public property (all UPPER case) it would have work being in the UI sequence, however, I didn't test that theory.

Resources