variables to subworkflow

Snow Tomcal
Tera Expert

Hi, 

I an trying to add variaqbles to workflow, this is what I did-

var gr = new GlideRecord('table');

gr.addQuery('sys_id','sys id of a record');

gr.query();

if(gr.next())

{

var wflw = new Workflow();
wflw.startFlow(wflw.getWorkflowFromName('give the workflow name'), gr, 'insert');

}

 

How do I add variables to the new workflow?

Thank You!

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Snow Tomcal 

I shared detailed steps here, have a look

Trouble Accessing variables from inbound action 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Rahul Talreja
Mega Sage
Mega Sage

Hi @Snow Tomcal ,

You need to create a input in workflow, and using that colum name in script, you can pass the parameter.
Script may somewhat look like :

var gr = new GlideRecord('table');

gr.addQuery('sys_id','sys id of a record');

gr.query();
var workVars = {};
workVars.input_1 = 'XYZ';
if(gr.next())

{

var wflw = new Workflow();
wflw.startFlow(wflw.getWorkflowFromName('give the workflow name'), gr, 'insert',workVars);

}
Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul