Expand my Community achievements bar.

SOLVED

Send variables to a subworkflow

Avatar

Level 7

Is there a way to send variables to a subworkflow? 

 

Like for example, I generate a variable a = 1 in a workflow, then call a subworkflow that takes A value and adds 5 to it. Is it possible? How can I do it?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @CampaignerForLife 

 

In your main wf define the variable like this:

vars.mainWFVar=1;

Master WF:

Manoj_Kumar__0-1679483835548.png

 

Then in the Sub-workflow you can use the same variables to add values to it:

vars.varfromMainWF = vars.mainWFVar + 5;
logInfo(vars.varfromMainWF)

Sub-workflow

Manoj_Kumar__1-1679483939891.png

 

And if you start the mast WF you see the updated added in the logs:

Manoj_Kumar__2-1679484007671.png

 

 

 


     Manoj
     Find me on LinkedIn

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hello @CampaignerForLife 

 

In your main wf define the variable like this:

vars.mainWFVar=1;

Master WF:

Manoj_Kumar__0-1679483835548.png

 

Then in the Sub-workflow you can use the same variables to add values to it:

vars.varfromMainWF = vars.mainWFVar + 5;
logInfo(vars.varfromMainWF)

Sub-workflow

Manoj_Kumar__1-1679483939891.png

 

And if you start the mast WF you see the updated added in the logs:

Manoj_Kumar__2-1679484007671.png

 

 

 


     Manoj
     Find me on LinkedIn
The following has evaluated to null or missing: ==> liql("SELECT id, subject, body, depth, post_time, author.login, author.id, author.rank, metrics.views FROM messages WHERE topic.id = '${topicId}' AND is_solution = true").data.items[0] [in template "analytics-container" at line 82, column 31] ---- Tip: It's the final [] step that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign acceptedAnswer = liql("SELECT... [in template "analytics-container" at line 82, column 5] ----