How to get output from a workflow using Mobile SDK
While the documentation mentions a workflow.evaluate command, this doesn't seem to be implemented in the Mobile SDK, and the WorkflowOperations class only has Cancel and Run operations. Run doesn't return output from the workflow.
Is there any way to get output from a workflow, or should I invoke a (custom) command from that workflow that works as a callback to the calling code?
-
Hi Berend,
How are you running the workflow? Through a command chain, via another workflow, or via C# in a Mobile SDK app?
Both the Run Workflow activity, and the workflow.run operation do return outputs in Mobile.
workflow.evalulate is not implemented in Mobile. This should not have been emitted in the docs for Mobile (it's Web only).
Thanks,
Jeff
0 -
Hi Jeff,
I'm using the WorkflowOperations class in a Mobile SDK app, e.g.
WorkflowOperations _workflowOperations;
...
var workflowArgs = new WorkflowArgs { Id = workflowId };
_workflowOperations.Run.Execute(workflowArgs);The execute method returns void, which is also what's in the documentation for workflow.run:
Runs a workflow with the given arguments. See the `workflow.evaluate` operation if you want to run a workflow and expect output values to be returned.
I looked into this a bit further, and noticed that await _wfOperations.Run.ExecuteAsync() in fact returns an IDictionary<string, object>, which contains the workflow output parameters.
0 -
Hi Berend,
The .Execute() method of every command/operation will always be void. This is because commands implement `ICommand` which defines: `void Execute(object parameter)`. As you've discovered, it's the .ExecuteAsync() methods that will have a return value.
Yes, the docs are wrong. The docs are generated from a repository which describes both Web and Mobile commands and operations. What you're seeing in the docs is effectively the description of the behavior in Web. I will create a ticket in our backlog to address.
Jeff
0 -
@... Thanks for your explanation.
I still have one more related question though: How can I pass input arguments to the workflow? I thought this would be straightforward, but somehow I can't get this working with a server workflow.
var workflowArgs = new WorkflowArgs
{
Url = "https://myserver/portal/home/item.html?id=9196d1ff94bd4c0eb5f61a6fc84f9aaa",
Inputs = new Dictionary<string, object> { { "input1", "Hi" } }
};
var result = await _workflowOperations.Run.ExecuteAsync(workflowArgs);The result variable does contain some output that I set in the workflow, so I'm sure it runs, but the getWorkflowInputs activity does not return anything.
When inspecting the body of the webrequest to /vertigisstudio/workflow/service/job/run, I see no inputs:
{"workflow":{"id":"9196d1ff94bd4c0eb5f61a6fc84f9aaa"},"inputs":{}}
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
4 kommentarer