Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to pass the scratch pad variable to the sub workflow

venkateshdhanap
Tera Contributor

Hi All,

I am having one workflow and this workflow uses one sub workflow.

I have using one scratchpad variable every where in the main workflow but i can't able to access the scratchpad variable in the Sub workflow.

How should i access or pass the scratchpad variable to the sub workflow.

Thanks

Venkatesh Dhanapal

3 REPLIES 3

Manik
ServiceNow Employee
ServiceNow Employee

hi Venkatesh,



Scratchpad variable in main workflow can be used in Subflow. Please follow the steps in the url mentioned below:



https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/administer/workflow-activities/t...



Hope this helps.



Thanks,


Manik



PS: Please mark helpful, correct or like if it helps.


adityaghosh
Tera Guru

Ti pass from parent to child, child wf must have input variables defined


find_real_file.png


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


Create scratchpad object in Run Script :



  1. workflow.scratchpad.my_obj = {};  
  2. workflow.scratchpad.my_obj.myVarOne = "Hello";  
  3. 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:


  1. workflow.scratchpad.returnedVal.myVarOne; // "Hello";  
  2. workflow.scratchpad.returnedVal.myVarTwo; // "World";  


use the return (y) inbuilt WF activity to fetch the values in parent.


Inactive User24
Mega Expert