The CreatorCon Call for Content is officially open! Get started here.

Generating tasks from a list collector in a Service Catalog Item

Pat Slattery
Mega Expert

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!

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

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();
}

View solution in original post

10 REPLIES 10

Thanks William, I ran into the same issue and adding split did the trick! Appreciated 🙂