Assign catalog task to the multiple assignment groups selected on catalog item variable

Ankita Gupte
Kilo Sage

Hello Experts,

 

I have list collector variable (choose_assgn_grp) on catalog item form referencing to Groups table, I want to trigger catalog tasks to any group selected on catalog item variable while raising a request. If one group is selected then one catalog task should tigger to that particular assignment group. If multiple groups are selected that multiple catalog task should trigger to those assignment groups.

 

Please advice how can I achieve this.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Ankita Gupte 

check my blog on how to create multiple catalog tasks

Using list collector in Flow Designer 'For Each loop' by converting string into array of string 

you can check if only 1 group is selected then create only 1 task

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Ankita Gupte 

are you using flow or workflow for your catalog item?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

 

Ankur Bawiskar  i have a similar scenario but am using workflow for catalog item?
can you please provide a solution for workflow.
Script in the catalog task activity:
var assgnmntGroup = current.variables.assignment_group.getDisplayValue();
var groupArray = assgnmntGroup.split(',');
var groupName = [];
var groupnames = [];
for (i = 0; i < groupArray.length; i++) {
    groupName = groupArray[i].trim();
    var gr = new GlideRecord('u_common_choice_values');
    gr.addEncodedQuery('u_active=true^u_catalog_item=b511385ec32a52909275be53e4013121^u_variable=de83da3d97f256d002e4b2e8c253afe7^u_valueIN' + current.variables.assignment_group.getDisplayValue());
    gr.addQuery('u_value', groupName.trim());
    gr.query();
    if (gr.next()) {
        var groups = new GlideRecord('sys_user_group');
        groups.addEncodedQuery('nameIN' + current.variables.assignment_group.getDisplayValue());
        groups.addQuery('name', groupName.trim());
        groups.query();
        if (groups.next()) {
            groupnames.push(groups.sys_id.toString());
            for (j = 0; j < groupnames.length; j++) {
                var groupSysIds = groupnames[j];
                gs.info('logs for groups ' + groupSysIds);
                task.short_description = "clusters";
                task.description = "This is a request to clusters";
                task.assignment_group = groupSysIds;
            }
        }
    }
}


With the above script am able to create only one catalog task getting assigned to last assignment group in the array. remaining are groups are ignored.

Ankur Bawiskar
Tera Patron
Tera Patron

@Ankita Gupte 

check my blog on how to create multiple catalog tasks

Using list collector in Flow Designer 'For Each loop' by converting string into array of string 

you can check if only 1 group is selected then create only 1 task

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankita Gupte
Kilo Sage

Thank you Ankur.

 

I tried flow designed, I was missing to use for each group. 

 

I added and its working fine.