Tuesday, May 15, 2012 6:31 PM
I have a StateMachine Workflow and under that in the initial state Entry activity I have dragged a CodeActivity which is internal having an InArgument<String> named RequestID.I am using WorkflowInvoker.Invoke to start the workflow.How do I pass the InArgument within the Codeactivity while starting the workflow?
Wednesday, May 16, 2012 3:51 AM
You can declare your INArgument at workflow level and pass that workflowInvoker or workflowApplication object.
Please follow this link
Activity wf = new WriteLine();
Dictionary<string, object> inputs = new Dictionary<string, object>();
inputs.Add("Text", "Hello World.");
- Marked As Answer by sandip_ray63in Wednesday, May 16, 2012 4:03 PM
Wednesday, May 16, 2012 1:48 PMModerator
Madhur is correct. You can declare the InArgument at the workflow root level, and pass in the value when you invoke the workflow. Then in the workflow designer, after you drop your custom code activity into the Entry action for the state, you bind to the workflow level InArgument to the InArgument of the custom code activity. There is an example of doing this in the WF4 Getting Started Tutorial How to create a workflow. There are 3 versions of workflows created (Sequential, Flowchart, and State Machine), I am linking to the State Machine tutorial here since you said you were using state machine:
In "To create the workflow variables and arguments" a MaxNumber InArgument is defined at the workflow level.
In "To add the workflow activities" in the Entry action of the first state we add an Assign activity, and then bind its Value InArgument to an expression that references that MaxNumber InArgument. You could do the same thing in your state machine, and if you just need the value of the argument (without any other expression evaluation like in my example) you could just put the argument name.
Steve Danielson [Microsoft]
This posting is provided "AS IS" with no warranties, and confers no rights.Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm