Assignment Rules and catalog tasks

Derek10
Tera Expert

Hi all,

 

I'm looking to have an assignment rule that runs when there is a blank catalog rule from a specific catalog item. (Not a RITM but the actual item itself)

 

Long and short is that if it is a catalog task from that item I want it to be routed based on location field of the requested user's profile record.

 

I'm trying to do this outside of workflow as I have to accommodate over 80 sites. I'm currently trying to do what was listed here:

 

Accessing a variable in an Assignment Rule in Catalog

 

but am not having any luck at all. I'm fairly new to service now and am trying to see the best approach. I currently have my catalog task in the workflow set to be blank, (no assignee or asignee group) to make this happen.

 

Looking for best approach options here.

 

Thanks!

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You could do something like that, although I would highly recommend populating your locations with this data so you don't need a bunch of if/else statements.



Your script should look something like this. I'm using setDisplayValue() and getDisplayValue() so you can work with the friendly names of your groups and locations rather than their sysids:


var loc = current.request.requested_for.location.getDisplayValue();


if (loc == 'Location1' || loc == 'Location2' || loc == 'Location3') {


      task.assignment_group.setDisplayValue('USA Support');


} else if (loc == 'Location4' || loc == 'Location5' || loc == 'Location6') {


  task.assignment_group.setDisplayValue('Canada Support');


} else {


    task.assignment_group.setDisplayValue('Global Support');


}


View solution in original post

8 REPLIES 8

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Derek,



Could you post the code you're using?



If this is specific to just one catalog item and workflow rather than all of your catalog tasks, I would use the script field inside of the catalog task activity to set the assignment group based on location. There aren't a lot of specifics in your post, but if I was setting this up I would have a support group specified for each location and use that to assign the task based on the requester. You could do it all in one line of code inside of the workflow activity. Something like:



task.assignment_group = current.request.requested_for.location.u_support_group;



That may be oversimplifying your situation a bit, but for a catalog task I typically use the task activity to manage the assignment rather than an assignment rule as the assignment tends to be more specific to different types of items than global like incident or change.


HI Brad,



Thanks for your reply! It is specific to one catalog item. We have groups in place for the various locations already and they cover multiple sites. Based on your comments it does seem like I have to put it into the workflow and on the script side of the catalog task.



So I'm guessing i'm looking at a condensed script assignment. IE:


if current.request.requested_for.location = x or x or x then


task.assignment_group == name of group



Does that sound correct? I haven't had java-script training yet so i'm learning as I go here. I was trying to avoid doing it inside the workflow originally, but if it is the best way and affects performance less then a global rule I am for it.


Brad Tilton
ServiceNow Employee
ServiceNow Employee

You could do something like that, although I would highly recommend populating your locations with this data so you don't need a bunch of if/else statements.



Your script should look something like this. I'm using setDisplayValue() and getDisplayValue() so you can work with the friendly names of your groups and locations rather than their sysids:


var loc = current.request.requested_for.location.getDisplayValue();


if (loc == 'Location1' || loc == 'Location2' || loc == 'Location3') {


      task.assignment_group.setDisplayValue('USA Support');


} else if (loc == 'Location4' || loc == 'Location5' || loc == 'Location6') {


  task.assignment_group.setDisplayValue('Canada Support');


} else {


    task.assignment_group.setDisplayValue('Global Support');


}


Most likely I will have to do that script. (thank you for providing the basis of it!) I would prefer a more dynamic way but I cannot populate the locations as my locations are being dynamically updated from our AD. Can you clarify a little more on your recommendation perhaps we can avoid the static code route.