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

Passing a variable value from subflow to Parent Flow

kuttti
Kilo Guru

Hello All,  I need to pass variable value  from "sub-workflow" to "parent-workflow".

Can anyone help me in achieving this.

 

Thanks!

9 REPLIES 9

Allen Andreas
Administrator
Administrator

Hello,

You would use "return value" for this.

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/workflow-activities/r...

Please mark reply as Helpful/Correct. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

kuttti
Kilo Guru

Hi Allen,

Thanks for your response! I have following questions

1. Should the variable(the value I am trying to return to Parent flow) should be on the Parent workflow.

2. Where exactly I need to put the "Return Value" in the subflow workflow.

 

Thank you!

Hello,

In your subflow when you place that on your parent workflow, there's a popup window that has a field that says: Map return value to -- so you can specify a scratchpad variable here using something like: workflow.scratchpad.subflow_result

find_real_file.png

Then use the return value workflow activity to set that value:

find_real_file.png

So you'd use that and then in your parent workflow, you can access it by using:

workflow.scratchpad.subflow_result

Please mark reply as Helpful/Correct. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Prasant Kumar 1
Kilo Sage

Hi,

You can return an object from the subflow to the parent.

Create scratchpad object in Run Script :-

workflow.scratchpad.my_obj = {};
workflow.scratchpad.my_obj.myVarOne = "Hello";
workflow.scratchpad.my_obj.myVarTwo = "World";

Use ${workflow.scratchpad.my_obj} as the single return value from subflow. And then you can call the properties from the parent by using whatever you called the return value like:-

workflow.scratchpad.returnedVal.myVarOne; // "Hello";


workflow.scratchpad.returnedVal.myVarTwo; // "World";

 

If i was able to solve your query, please mark my answer correct and helpful.

Thanks & Regards

Prasant kumar sahu