michael_stefani
Enthusiast
Enthusiast

Workflow Output Parameters

Jump to solution

I have a workflow that returns an array of type string.  I need to call this workflow from a custom action and have the action return said array.  I've been stumbling around with executing a workflow via javascript and got that part pretty much down.  As best I can tell the only way to retrieve the output though is via the "getOutputParameters" method on the workflowtoken.  I'm a little confused on exactly what type of data this is returning though.  The API documentation mentions some dunes...type that I've never heard of.  What's the best way to get that array output back into an array so I can use it as my Action output?

    var outputParams = wfToken.getOutputParameters();

        var value = outputParams.get("apps");

System.log(value);

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee

Hi,

WorkflowToken#getOutputParameters() returns an object of type Properties (and documentation for this type is available in the API Explorer).

The code sample you've provided shows how to get the array output:

1) first, you get the output parameters from the workflow execution:

var outputParams = wfToken.getOutputParameters();

2) then, you retrieve the output parameter value from this Properties object. to fetch the value for a given key, you need to provide the key name; in your case, the key name would be the workflow output parameter name

var value = outputParams.get("workflow_output_param_name");

or, if you cannot hardcode the name of the output parameter, but know that your workflow has exactly one output parameter

var value = outputParams.get(outputParams.keys[0]);

And now the value variable contains the array of type string which has been returned from your workflow, so you can return it from your custom action.

View solution in original post

0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee

Hi,

WorkflowToken#getOutputParameters() returns an object of type Properties (and documentation for this type is available in the API Explorer).

The code sample you've provided shows how to get the array output:

1) first, you get the output parameters from the workflow execution:

var outputParams = wfToken.getOutputParameters();

2) then, you retrieve the output parameter value from this Properties object. to fetch the value for a given key, you need to provide the key name; in your case, the key name would be the workflow output parameter name

var value = outputParams.get("workflow_output_param_name");

or, if you cannot hardcode the name of the output parameter, but know that your workflow has exactly one output parameter

var value = outputParams.get(outputParams.keys[0]);

And now the value variable contains the array of type string which has been returned from your workflow, so you can return it from your custom action.

View solution in original post

0 Kudos
michael_stefani
Enthusiast
Enthusiast

Thanks,  i kind of figured it out while I was waiting for a response.  In the API documentation it shows the return type as something funky.  ch.dunes.scripting.jsmodel.jsproperties.  Despite that in testing it looks like it just returned a type of array which I could just dump to my output.  Thanks,

0 Kudos