How to trigger workflow from another workflow

ramesh_r
Mega Sage

Hi All,

I want to trigger sub-workflow using script.

 

Example: I have Workflow A and Workflow B

1. Workflow A is currently running and there is one run script activity in the Workflow A

2. I want to trigger the Workflow B from the Workflow A run script 

 

Please guide me on how to do that or please provide any script to active this

 

Thanks

Ramesh R

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

This is the sample script to trigger workflow from script

var inc = new GlideRecord('incident');
inc.get('number', 'INC001');

var wf1 = new Workflow();


wf1.startFlow(wf1.getWorkflowFromName('give the workflow name'), inc, 'update');

Regards
Ankur

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

This is the sample script to trigger workflow from script

var inc = new GlideRecord('incident');
inc.get('number', 'INC001');

var wf1 = new Workflow();


wf1.startFlow(wf1.getWorkflowFromName('give the workflow name'), inc, 'update');

Regards
Ankur

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

Hi Ankur,

 

Thanks for the help.one more question

is that possible to pass some value while starting the workflow from the script .?

 

Thanks

Ramesh R

Hi,

yes you can pass information to the calling workflow using this

check the approach I shared in below link

Trouble Accessing variables from inbound action

Regards
Ankur

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