Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Best way to pass variables or parameters to a sub-workflow?

Avatar

Level 2

I am attempting to create shared (sub) workflows which other users could reuse them to do common tasks. What would be the best/proper way to pass variables that would work as parameters to these sub-workflows?

 

Atm I am using instance variables, but I have a major issues with it. The following workflow, for example:

 

nlclient_C0kTDNBQBT.png

Both sub-workflows use the instance.vars.parameter. Internally, on my sub-workflow, I would build a logic that halts the execution if the variable/parameter is not properly set. But, if the user forgets to set it on the second fork path, it will use the same instance.vars.parameter value of the first fork path.

 

Does anyone have any suggestions on how to approach it?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

 

AFAIK it's just instance.vars available to sub-workflow, though can also use xtk:option with get/setOption().

Set a diff parameter for each path?

 

Thanks,

-Jon

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi,

 

AFAIK it's just instance.vars available to sub-workflow, though can also use xtk:option with get/setOption().

Set a diff parameter for each path?

 

Thanks,

-Jon

Avatar

Level 2

Considering the workflow description field

As a sub-workflow is not going to be "readable" but the template, I propose another solution for the description field.


Using the sub-workflow activity, place your configuration code as JSON:

subWorkflow.desc = JSON.stringify({ myVariable: "some value" });

AdrianESanchez_0-1669648463381.png


Then within the workflow template (sub-workflow) read that config from the description field:

var wkfConfig = JSON.parse(instance.desc);

AdrianESanchez_1-1669648505303.png

 


Regards.