Calling a workflow inside a workflow

Geeky
Kilo Guru

How can I call a workflow inside a workflow?

E.g. I have a form and a field called Workflow which is a reference field to the wf_workflow table.

I have the main workflow and inside that one more workflow should be called by fetching the data from the field which I created.

I know how to fetch the workflow id from the reference field I created inside the main workflow but unable to find how can I trigger a workflow with workflow id?

1 ACCEPTED SOLUTION

sachin_namjoshi
Kilo Patron
Kilo Patron

use below code to trigger workflow from run script activity in your parent workflow.

var wflw = new Workflow();


wflw.startFlow(wflw.getWorkflowFromName('give the workflow sys_id_from your reference variable'), current, 'update');

 

Regards,

Sachin

 

View solution in original post

9 REPLIES 9

Prateek kumar
Mega Sage

Here is the article that will help you:

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


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

not useful. I already read that but it's not explaining how can I invoke it from workflow id dynamically.

sachin_namjoshi
Kilo Patron
Kilo Patron

use below code to trigger workflow from run script activity in your parent workflow.

var wflw = new Workflow();


wflw.startFlow(wflw.getWorkflowFromName('give the workflow sys_id_from your reference variable'), current, 'update');

 

Regards,

Sachin

 

Below code worked with some modification from your code. Passed name instead of sys_id.

 

But I want to pass sys_id

 

var wflw = new Workflow();


wflw.startFlow(wflw.getWorkflowFromName('Workflow Name not sys id'), current, 'update');