Using a list collector to generate multiple tasks with their own approvals

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2018 11:36 AM
I am working on having a workflow generate multiple tasks based on all the items selected in a list collector. I have been able to do that piece. The part I am struggling with is to have approvals that are unique to each item selected in the list collector. The items displayed in the list collector are tied to a CI with an approval group.
Some options I have been working with is to have a RITM generated for each CI listed in the list collector or have a task for each item and have 1 RITM total. Either way the part I am struggling with is how do I get the approvals to be unique for each item since the tasks are generated by a run script.
The newest approach I have been working on is generating a RITM per item select. The piece i haven't been able to figure out is to populate the item details such as getting a workflow to trigger on it and the variables to carry over.
Has anyone done anything similar where you need a unique approval for each item in a list collector and if someone rejects, it only stops that portion of the overall request?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2018 01:16 PM
Keep it a single RITM and add a Run Script activity in your workflow. Something similar to below:
var itemArr = current.variables.variable_name.toString().split(',');
for(var i = 0; i < itemArr.length; i++){
var item = new GlideRecord('item_table_name');
item.get(itemArr[i].toString());
var approval = new GlideRecord('sysapproval_approver');
approval.newRecord();
//create approvals for current RITM
approval.sysapproval = current.sys_id.toString();
//approval.approver = pass a user sys_id for user approvals
//Set group Approvals based on item
approval.group = item.group_field.toString();
approval.insert();
}
This will create unique approvals for all the items.
After that you need to add IF activity to check if approvals are approved and based on that you can create tasks.
Mark correct is that helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2018 01:22 PM
That is sort of what I was trying, the issue i ran into is any rejections should stop the task for only the item it was requested for in the list collector.
I figured out a different method where I created a field on the task table that is set by the script that generates all of the tasks for each item in the list collector. I have another workflow on the task level with a condition that matches what was set by the task generator script and that workflow creates an approval for each task and sets the state to open when approved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2019 08:06 AM
Hi Alex,
I have a very similar requirement. Were you able to get approvals for your particular catalog tasks?