The CreatorCon Call for Content is officially open! Get started here.

Get outputs of Sub workflow in workflow editor run script

AM24
Giga Guru

Hello, I have a run script in workflow editor that fires another workflow.

 

var wf = new global.Workflow();
var context = wf.startFlow('dslfjkdsj3dkfj3dls', current, current.update());

 

The sub-workflow has a couple of Activity Outputs. I was wondering how I would be able to grab those to use in my original workflow. I didn't know the syntax for that. Thanks!

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

Is there a reason you're using a Run Script instead of the Workflow Instance activity?  You create this activity by dragging a Workflow (the sub flow) from the Workflows list on the right of the editor, to the checked-out main workflow, then connect it where you like.  This activity has a Map return value field where you can put something like

${workflow.scratchpad.subflow_result}

which you set using a Return Value activity in the sub-flow (for example 'error' in the Value field of this activity), then you can access it coming out of the Workflow activity in an if activity, or whatever, the same as any other scratchpad variable

if (workflow.scratchpad.subflow_result == 'error') { ...

The other advantage to using the Workflow Instance activity is that the main workflow waits for the sub-flow to reach the End before returning to the main workflow to advance to the next activity - unless you don't want it to, then you can run it parallel to other activities.