Create catalog task based on List collector and set assignment group

Community Alums
Not applicable

Hi All,

We have a requirement to create separate task for each option selected in the list collecter and also set assignment group. List collector is referencing to "u_list_collector_table" and we have a reference field(Assignment Group) in this table that references to group table. I'm able to create task for each option selected in list collector but unable to set assignment group. Can someone help me on this?


Below is my code in Run Script activity:

var reports = current.variables.u_list_collector_variable.getDisplayValue().split(',');
for (i = 0; i < reports.length; i++) {
    var tabl = new GlideRecord('u_list_collector_table');
    tabl.get(reports[i].toString);
 
    var sct = new GlideRecord('sc_task');
    sct.initialize();
    sct.short_description = reports[i] + ' Access Request';
    sct.assignment_group = tabl.u_assignment_group.toString();
    sct.request_item = current.sys_id;
    sct.order = 100;
    sct.state = '1';
    sct.insert();
}
7 REPLIES 7

Community Alums
Not applicable

hi @Riya Verma 

i have tried your code but it is not creating sctask itself.

 

Prateek kumar
Mega Sage
var reports = current.variables.u_list_collector_variable.split(',');
for (i = 0; i < reports.length; i++) {
    var tabl = new GlideRecord('u_list_collector_table');
    tabl.get(reports[i].toString());
 
    var sct = new GlideRecord('sc_task');
    sct.initialize();
    sct.short_description = reports[i] + ' Access Request';
    sct.assignment_group = tabl.u_assignment_group;
    sct.request_item = current.sys_id;
    sct.order = 100;
    sct.state = '1';
    sct.insert();
}

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

Hi @Prateek kumar 

In your first line if script dose'nt have getDisplayValue() runscript is not creating SCTask. I have addedd getDisplayValue() to the script and tried then it's creating SCtask but not assigning the assignment group(s).
FYI : My List collect table has three fields
1.Report (String)
2.Approver (Reference to User table)
3.Fullfilment Assignment Group (Reference to group table)
So based on Reports(List collector variable) selected on form, Sctask should be created and also Assignment group should be auto assigned.