Set assignment group based on variables in a variable set

thomast63
Mega Contributor

I have a Catalog Items that I would like to have auto-assigned based on a value from one of the variables in the variable set. The variable is a reference field called "requestors_catalog_default" and  it references the location table. can I do this via the workflow, or do I have to use a catalog client script? IF so, how would I do that?

Thanks!

 

1 ACCEPTED SOLUTION

Tanaji Patil
Tera Guru

Hi,

 

Before thinking on the solution you should check these-

  1. You should get it clear what you wnat to assign- RITM (i.e. the records automatically created in sc_req_item table once the request is submitted) or a catalog task under it (which is optional and created using the 'Catalog Task' activity in the workflow). Both could be assigned using the assingment_group field and depends on your process.
  2. You should check if this logic is applicable to only a particular catalog item or all catalog items. If my understanding about your requirement is right then you need for only a particular catalog item.

 

Once these are clear then based on the ansers you should think where to put these.

You could do the assignment either from-

  • Workflow / Flow designer (Recommended)
  • Business rule (Not recommended)
  • Assignment Rule (Is used as default assignment group if none of the above is assigning the ticket)

 

Assume that you want to assign the RITM created by a particular catalog item based on a variable 'requestors_catalog_default' here is what you need to do-
Next to 'Begin' activity add a 'Run Script' activity with a code which looks something like this:

var locationName = current.variables.requestors_catalog_default.name;

if (locationName == "name_of_location_1") {
current.assignment_group.setDisplayValue("name_of_assignment_group_1");
}
else if (locationName == "name_of_location_2") {
current.assignment_group.setDisplayValue("name_of_assignment_group_2");
}
.
.
.
else {
current.assignment_group.setDisplayValue("name_of_default_group");
}

 

Assume that you want to assign the catalog task created under a particular catalog item using 'Catalog Task' workflow activity based on a variable 'requestors_catalog_default' here is what you need to do-
In the 'Catalog Task' activity put code something similar to this in the Advanced script-

var locationName = current.variables.requestors_catalog_default.name;

if (locationName == "name_of_location_1") {
task.assignment_group.setDisplayValue("name_of_assignment_group_1");
}
else if (locationName == "name_of_location_2") {
task.assignment_group.setDisplayValue("name_of_assignment_group_2");
}
.
.
.
else {
task.assignment_group.setDisplayValue("name_of_default_group");
}

You could use Flow Designer istead of workflow by activating and using 'Flow Designer support for the Service Catalog' plugin.

In case this assignment logic is applicable to all the catalog items then I would suggest you to put it in Assignment Rules with script.

You can check out OOTB workflows, flows and assignment rules for getting an idea on what they provide.

 

Hope this helps!

 

View solution in original post

21 REPLIES 21

Matt Kozinski
Kilo Guru

Hi.

I understand the assignment group should be set on SCTASK.

You should set it in the workflow. You need to know the path from your variable to the assignment group or a link between them, then you can browse the table, e.g.:

var lookUpGroup = new GlideRecord('sys_user_group');
lookUpGroup.addQuery('location', current.variables.requestors_catalog_default);
lookUpGroup.query();

Then assign it based on your conditions using:

task.assignment_group = lookUpGroup;

In this method do you only change "requestors_catalog_default" to your variable? How about  'location'??

 

And can both of these pieces of text be in the task, are any other settings also needed? getting range of errors

thomast63
Mega Contributor

so I would put that in the create task part of workflow? Sorry new to this.

Yes, in the create task part of workflow. I don't know your exact requirement, but I'm assuming the assignment group should be populated on SCTASK where the actual work is performed, at least this is how we usually do it.

thomast63
Mega Contributor

I ended up doing this in task , Not sure if its the right way but its working.

 

task.short_description = current.short_description;
if(current.variables.catalog_default == "walker support"){task.assignment_group = "736468de4fd95200cd3d97dd0210c7db";}  
if(current.variables.catalog_default == "bedford support"){task.assignment_group = "bf6468de4fd95200cd3d97dd0210c7e0";}
if(current.variables.catalog_default == "ahuja support"){task.assignment_group = "f36468de4fd95200cd3d97dd0210c7d9";}
if(current.variables.catalog_default == "bishop 5 & 6"){task.assignment_group = "275e76bb0ff43600bc1b22d8b1050e22";}
if(current.variables.catalog_default == "csc support"){task.assignment_group = "336468de4fd95200cd3d97dd0210c7e2";}
if(current.variables.catalog_default == "elyria support"){task.assignment_group = "f76468de4fd95200cd3d97dd0210c7dd";}
if(current.variables.catalog_default == "executive support"){task.assignment_group = "7e306f8e4fa2560063fa495d0210c7c3";}
if(current.variables.catalog_default == "geauga support"){task.assignment_group = "7b6468de4fd95200cd3d97dd0210c7e2";}
if(current.variables.catalog_default == "geneva support"){task.assignment_group = "b36468de4fd95200cd3d97dd0210c7e3";}
if(current.variables.catalog_default == "lakeside support"){task.assignment_group = "7f6468de4fd95200cd3d97dd0210c7d9";}
if(current.variables.catalog_default == "lerner support"){task.assignment_group = "97e3c30e4f0a9600cd3d97dd0210c779";}
if(current.variables.catalog_default == "macdonald support"){task.assignment_group = "0c7e2fe44fbed64063fa495d0210c758";}
if(current.variables.catalog_default == "mather support"){task.assignment_group = "f76468de4fd95200cd3d97dd0210c7da";}
if(current.variables.catalog_default == "msc support"){task.assignment_group = "bf6468de4fd95200cd3d97dd0210c7e0";}
if(current.variables.catalog_default == "parma support"){task.assignment_group = "f36468de4fd95200cd3d97dd0210c7df";}
if(current.variables.catalog_default == "portage support"){task.assignment_group = "776468de4fd95200cd3d97dd0210c7e0";}
if(current.variables.catalog_default == "rainbow support"){task.assignment_group = "fb6468de4fd95200cd3d97dd0210c7db";}
if(current.variables.catalog_default == "richmond support"){task.assignment_group = "376468de4fd95200cd3d97dd0210c7e4";}
if(current.variables.catalog_default == "samaritan support"){task.assignment_group = "09d44da04f6e1200964d2ae6f110c7a0";}
if(current.variables.catalog_default == "seidman support"){task.assignment_group = "776468de4fd95200cd3d97dd0210c7dc";}
if(current.variables.catalog_default == "uh samaritan support"){task.assignment_group = "64a645e04f6e1200964d2ae6f110c7b7";}
if(current.variables.catalog_default == "weekend support"){task.assignment_group = "49c984524f42fa000d1c97dd0210c7c9";}
if(current.variables.catalog_default == "westlake support"){task.assignment_group = "a9bb08d0db1eebc0c418720ebf961947";}