How to call a sub-workflow from within a workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 07:59 AM
Hi: I'm creating a service catalog to assign assignment groups to a user. I want to have the main workflow call a sub-workflow that will update the user record with one assignment group each time. So the main workflow will have the user record and all assignment groups and will pass the user with only one assignment group to the sub-workflow. Can this be done?
Appreciate your advice! Rita

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 08:01 AM
Hi Rita,
You can use the workflow.scratchpad object to pass information to the subflow.
My initial question is how do you know which assignment group to use if you have ALL assignment groups and want to call the subflow with just one? Are you looking to call the subflow for each assignment group in the list you have somehow compiled?
Using the Workflow Scratchpad - ServiceNow Wiki
Using Subflows - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 08:36 AM
Hi Chuck: So what I want to do in the main workflow is have a for loop in a 'wait for condition' activity. Something like:
var user = current.variables.caller_id;
var assignment_groups = current.variables.assignment_groups;
//note variables.assignment_groups is a List Collector category item variable
for (var i = 0; i<assignment_groups.length; i++){
var group = assignment_groups[i];
workflow.scratchpad.ag = group;
workflow.scratchpad.usr = user;
// now how to I call the subflow here?
}
Thank you!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 08:42 AM
Hi Rita,
Not sure using that approach. Is it possible to pass all groups and let the subflow deal with the parsing/looping?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 08:46 AM
Why in a sub workflow and not just via a quick script and a loop ?
Sub workflows is easy. but seems unusual to me.