How to invoke a Workflow which has an input argument
I'm interested in any assistance from anyone who has been able to invoke a Workflow, which has an input argument, from the Silverlight Viewer or from the Viewer.html page using javascript.
From the Silverlight Viewer, the Quickstart example uses the Viewer xml configuration:
<Tab DisplayName="Invoke Workflow">
<Group>
<Button Name="Invoke Workflow" Command="RunWorkflow" CommandParameter="AddNumbersWorkflow" ImageUri="IconPlaceholder32x32.png" ToolTip="Invoke the Add Numbers Workflow" />
</Group>
</Tab>
to invoke the AddNumbersWorkflow.
From javascript in the Viewer.html page, the same Workflow can be invoked using:
silverlightPlugin.Content.essentialsViewer.RunCommand("RunWorkflow", "AddNumbersWorkflow");
But I am unable to find an example of invoking a Workflow which has an input argument.
Such a Workflow can be invoked from the simulator within the Workflow Designer or from the Site REST endpoint by assigning the input argument value as required before running.
How can this be done from the Silverlight Viewer or from the Viewer.html page? Can anyone assist?
-
Arguments are pretty easily passed to Workflows from the Silverlight Viewer. Using Essentials Manager, once you add the workflow to the site, open its properties. Once there, you have the 3 text fields to modify the ID, Display Name and Uri. Below these, there will be a link to "Properties". Click this and add your argument name and value.
/customer/servlet/servlet.FileDownload?file=00P6000000e888EEAQ
Inside a workflow, add the same argument name (ArgDemo in this case) to your workflow using the workflow Argument tab, between Variables and Imports. The ArgDemo name then is a variable you can reference inside your workflow.
Hope that answers your question!
0 -
Thanks for your reply Shawn
Your solution works well for Workflows where the argument values are fixed.
The scenario I have is needing to invoke a Workflow assigning a different argument value each time,the Workflow being invoked from outside of the Viewer.
Is there a way to invoke a Workflow which has an argument using the RunCommand method?
0 -
That clears your question up a little more. I'm not the expert on this, but I believe Workflow parameters are supplied by the REST core, not the viewer technology. The commands you've showed are for the silverlight viewer specifically calling a workflow. So you are not seeing the true REST call to execute the workflow itself. My suspicion is that dynamic parameters are not supported in the Silverlight viewer. If you create your own silverlight viewer module, you likely can call the REST interface for the workflow and provide your own parameters. That is where my knowledge stops. Hopefully someone will reply to this and teach me how to do that too!
Thanks,
Shawn.0 -
We need something similar to this as well. I'm creating a workflow to log user statistics. The workflow will run on viewer startup, get the current user's name, then call a web service to log the user information to a database. Getting the username is no problem, but getting the Viewer that the user is using to hit the Essentials Site with is more difficult.
Shawn's solution works in that we can pass an argument to the workflow to tell us what Site the user is coming from. But if we have multiple viewers on a site, say a SL Viewer and an HTML viewer, then that static value at the Site level is not enough to tell us what Viewer is being used. This is where it would be nice to be able to pass an input argument straight from the Viewer into the Workflow.
This wouldn't be hard to do with custom code:
- In the workflow add a DynamicExternal activity (0 inputs, 1 string output)
- Create a custom Silverlight module to Handle the DynamicExternal activity.
- All the custom module would need to do is read in some string from the Viewer.xml file (or derive it dynamically) and return that to the workflow.However, custom code adds maintenance costs and I'd much rather have an out of the box way to do it.
0 -
I see that you can add a property to a workflow that has a value, is there a way to change that value with an argument from the url command line that opens the site? this could solve some problems.
J
0 -
Hi Corporate Mapping, TMR
If you are able to get this:
silverlightPlugin.Content.essentialsViewer.RunCommand("RunWorkflow", "AddNumbersWorkflow");
to run as you stated, have you tried this:
silverlightPlugin.Content.essentialsViewer.RunCommand("RunWorkflowWithArguments", "WorkflowID=AddNumbersWorkflow&arg1=3&arg2=18);
where arg1 and arg2 are arguments configured against the workflow AddNumbersWorkflow.
From the SL1.6 and 1.5.2 Admin & Developer Guide document:
Executes a workflow, where the workflow ID is defined by a key-value pair in the dictionary, where the key is "WorkflowID" (case insensitive). The value corresponding to the "WorkflowID" key should be the ID of the workflow you wish to run. All other keys in the dictionary are matched to workflow arguments, and are sent to the workflow when it is started. Any dictionary keys which do not map to workflow arguments are ignored.
Thanks
Ralph
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
6 kommentarer