Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

How to set / script an assignment group on sctask based on Catalog Item variable

jmonnette
Giga Contributor

We have a "New Hire Request" catalog item.

We have multiple help desk groups.

We would like to assign a specific help desk group based on the location variable in the catalog item.

Any help on this would be awesome!

Thanks

 

1 ACCEPTED SOLUTION

If you use "getDisplayValue()", the correct script will be:

if (current.variables.nh_location.getDisplayValue() == 'name_location1') {
task.assignment_group = 'sys_id_group1';
if (current.variables.nh_location.getDisplayValue() == 'name_location1') {
task.assignment_group = 'sys_id_group2';
}

 

If without "getDisplayValue()", correct  script:


if (current.variables.nh_location == 'sys_id_location1') {
task.assignment_group = 'sys_id_group1';
} else if (current.variables.nh_location == 'sys_id_location2') {
task.assignment_group = 'sys_id_group2';
}

if multiple locations equal a certain helpdesk, your can be used operator "OR" -||


Example:


if (current.variables.nh_location == 'sys_id_location1' || current.variables.nh_location == 'sys_id_location2') {
task.assignment_group = 'sys_id_group1';
} else if (current.variables.nh_location == 'sys_id_location3' || current.variables.nh_location == 'sys_id_location4' || current.variables.nh_location == 'sys_id_location5') {
task.assignment_group = 'sys_id_group2';
}

Or there are many combinations, use switch case or create a table of group and location mappings, and select the required group when accessing this table by location

View solution in original post

8 REPLIES 8

SanjivMeher
Mega Patron

You can add a business rule on task

 

current.assignment_group = current.request_item.variables.location.group_field_name;

 

 

bardakov
Tera Expert

If your sctask created from workflow, in script section you can check the location and specify the required assignment group


For example:

if (current.variables.location == 'sys_id_location1') {
task.assignment_group = 'sys_id_group1';
} else if (current.variables.location == 'sys_id_location2') {
task.assignment_group = 'sys_id_group2';
}

 

 

jmonnette
Giga Contributor

Viktor - thanks for replying. Apprecaite your help!!

You are correct this variable is from a catalog item that references the location.
The variable name is: nh_location

The use case is:
We have a New Hire Request Catalog item that runs a worflow that create sctasks.
We have 96 Locations and 13 Help Desk Assignment Groups.
We need to associate a location with a help desk group for certain tasks.

So would this be the correct script?

if (current.variables.nh_location.getDisplayValue() == 'sys_id_location1') {
task.assignment_group = 'sys_id_group1';
if (current.variables.nh_location.getDisplayValue() == 'sys_id_location1') {
task.assignment_group = 'sys_id_group2';
}


or would it be this?

if (current.variables.nh_location == 'sys_id_location1') {
task.assignment_group = 'sys_id_group1';
} else if (current.variables.nh_location == 'sys_id_location2') {
task.assignment_group = 'sys_id_group2';
}


Also how can I write this script so that if multiple locations equal a certain helpdesk

If these groups aren't changing, you could create a custom table to hold two specified fields: Assignment Group, Location. Then, based off whatever the user picks in the dropdown, query that table and grab the location correlated with that group.