- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2018 07:03 AM
Morning!
I am looking to generate tasks based on selection of values from a list collector that I have added to a catalog item.
I.E.> if multiple values are selected, generate tasks out to those teams
Selections == Workday;OKTA;Sailpoint
Workday > Send task to workday services
OKTA > Send task to Okta Servicesa
Sailpoint > Send task to Sailpoint Services
Currently i have 6 list collector fields that contain different reference qualifiers limting data points coming from the applications table in CMDB. The values from these list collectors then will need to generate SCTASKS when selected to the assignment group indicated on the CI record.
Looking for advice on the best practices of how to achieve this.
Thank you in advance!
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2018 07:19 AM
You'll want to use a 'Run script' activity in your request item workflow to do this. The script will iterate through the values in the list collector variable and then create an 'sc_task' record for each one.
// Create 'sc_task' records for each item in the list collector var
var options = current.variables.MY_LIST_COLLECTOR_VAR_NAME;
// Iterate through the options
for (i=0; i < options.length; i++) {
// Query for the current CI
var ci = new GlideRecord('cmdb_ci');
ci.get(options[i]);
// Create a new task record for the current CI
var sct = new GlideRecord('sc_task');
sct.initialize();
sct.short_description = 'Task for ' + ci.name;
sct.assignment_group = ci.assignment_group; // Make sure this field name is correct!
sct.request_item = current.sys_id;
sct.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2018 07:38 PM
Mark,
Additional question that I did have was around passing variables from the RITM to the SCTASK's that are being created.
Since these are being auto generated, I assume that I will need to state these in the task generation code where the asssignment group is being set, however that is not being set from the same location.
Any advice here?
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2019 04:56 PM
Hey Mark,
Thank you for sharing this code 🙂
How about updating CI records? This code is actually creating the Catalog Tasks based on the list collector, How can this be accommodated if it has to check for a CI record based off the CI sys_id and update certain information say Operational status?
Could you please provide a code to update the Operational Status based on the CI selected in the list collector?
Thanks in Advance.
Praveen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2020 02:47 AM
Hi Mark,
Same requirement as above but some add on,
Before generating tasks based on the list collector variable. It should have approval activity(user approval based on list collector variable. for ex: workday--->user1, Okta----->user2 and so on).
It should generate tasks only for the approved records not for the rejected records.
Please help me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2020 03:37 PM
Hi Muktha,
Sorry for the late response.
You can add an Approval Activity by querying the approval and if approved generate the task.
Same way for Rejected and cancel the request.
You can modify it either by using flow designer or Workflow Editor.
Regards,
pK

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2021 08:19 AM
Thanks for the info, Mark! I used it on a list collector based on the the sys_user table and found that it didn't work properly for me until I modified the first line to:
var options = current.variables.MY_LIST_COLLECTOR_VARIABLE_NAME.toString().split(',');
Just in case anyone else runs into the same issue!