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

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!

 

thomast63
Mega Contributor

I have a Group of catalog Items that will use this same workflow. So It looks like what I posted is working and I see how Tanaji can work also.

I have not used the flow designer does that work better than the workflow editor??

Okay thats good to hear that its working for you.

Right now I would say flow designer is not better but more user friendly and easier for non-technical people. Also ServiceNow is moving towards Flow designer completely. I would recommend having a look into it and if possible start using it over workflow whenever and wherever possible.

Thanks for that info. I will look into it.

If your issue/query is solved please close this thread by marking the right answer.

Thank you!