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 inputs or scratcpad values from Parent workflow to sub workflow.

Suvarna
Kilo Explorer

i want to pass the scratchpad values from parent to child workflow using parallel flow launcher.

am setting some scratchpad values in parent workflow if i try to access that values in child workflow means am getting an error as "Undefined". 

Thank you for any help. 

1 ACCEPTED SOLUTION

Not sure if you've read this, but you need to define your inputs from your parent, to your child, and make sure to do a return value from the child to the parent:

https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/administer/workflow-activities/task/t_VariableWorkflowSubflow.html

View solution in original post

6 REPLIES 6

Omkar Mone
Mega Sage

Hi 

Please send a code snippet of how you're setting and retrieving the values from scratchpad.

Thanks.

Parent Workflow:

find_real_file.png

 

in parent Workflow Am calling my sub workflow like this 

workflow.scratchpad.identifier = current.identifier;
var desc = '38954899#38954870#38954909#38954814';
var split = desc.split("#");
//gs.info("Split Val/ues new"+split);
for(var i=0;i<split.length;i++){
gs.info("Main workflow Value "+split[i]);

workflow.scratchpad.rdmidVal = split[i];
'Gloss Error WF';

gs.info("RDMId Value in Main Workflow after calling workflow");
}

or 

coordinator = new WorkflowCoordinator( {workflow:'Gloss Error WF'} );
for(var i=0;i<split.length;i++){
coordinator.add(
{ RDMID:'38954870'; // inputs to subflow ,you need to define input in the sub flow first to use this
// input2:'xyz',
}
);
}

coordinator;

 

know i want to set an scratchpad value in parent workflow and retrieve in sub workflow how can i achieve that.

Hi 

You set the value as workflow.name_of_variable ="someValue".

and retrive as var wfVar = workflow.name_of_variable;

Check this once and let me know.

Thanks.

Hi Omkar ,

i tried above solution but still am getting as undefined.

In parent workflow:

workflow.getData = "Welocome";

 

In Child Workflow:

var myname = workflow.getData;
gs.info("MY NAME GETDATA Values!@# "+myname);