Automatically setting assignment group if caller is from a certain state

kenneth2k1
Kilo Expert

Hi all:

I can't quite figure out how to automatically set the assignments group is the person reporting the incident/request is from a certain state. We have a number of users who should be assigned to a specific assignment group if their user account lists their city as Portland. It doesn't look like this can be done by an assignment rule, does this have to be worked into the workflow? If so, could you help me with the script syntax?  

Thanks for any help or insight on this!

1 ACCEPTED SOLUTION

Yes I had noticed that too



I fixed it, yet it still wasn't working as expected. First, I have discovered that there will need to be different methods for incidents and requests.



For example, for incidents, a business rule will get overridden by an assignment rule. And for requests, a business rule or client script will be overridden by a script that is run in a workflow. We have auto assignment happening by assignment lookup rules, assignment rules, and workflows depending on request or incident. So the answer is tricky.



2015-02-26_15-49-10.jpg



With servicenow help desk's help, we have been able to get a resolution by using an assignment lookup rule that runs on the incident table to assign to the desired group if the location is "Portland." The order is set so that it is before any other rule that sets an assignment group. So the other suggestions made in this thread might have worked, but there are multiple ways to auto assign the group, and these assignment data lookup rules always take precedent



...except with requests. Working with SN on those, since the technician was also having a difficult time determining what takes precedent over what, and what the proper way might be to set these (currently setting them in the workflow will probably be the solution).


View solution in original post

24 REPLIES 24

Spelling mistake


gs.log('Caller Location :'+current.caller_id.location);



if(current.caller_id.location == 'xyz')


{




}


If your creating incidet by using record producer. Follow the below steps.



Open you record producer. In producer script write below code.



if(producer.location == 'Portland')


{


current.u_time_to_assign.setDiplayValue('xyzgroupname');


current.update();


}


ok corrected the spelling mistake, but are you sure this is correct?



current.u_time_to_assign.setDiplayValue('xyzgroupname');



could you point me to a reference of how to use "current" keywords?



Thanks,


Hello Ken,



u_time_to_assign is a custom column that I don't think you have since you never mentioned it. It should be like this:


current.assignment_group.setDisplayValue("PortlandSupport");



current contains an object with the record that is being modified. with the dot (.) you access its properties.



If you want to assign a value to a property you can do it like this:



current.property = "value";





Since assignment group is a reference record you can use setDisplayValue() to use the name of the assignment group, otherwise you would have to provide the sys_id of the assignment group:




current.assignment_group = <sys_id of the assignment group>



Also, location is a reference field, if you do current.caller_id.location it is going to give you the sys_id of the location.




ServiceNow allows dot walking, which means you can access the properties of the reference record too, like so:




current.caller_id.location.state






hello: thanks for the reply. So here is the code as I have it:



var UserLoc= producer.location; // This will get the reporter's location


if(UserLoc == '56d1e491185c9500e83321ca641a6099')//Portland
{
        current.assginment_group.setDisplayValue('SN_Shiftwise_ServiceDesk');
}
current.update();


gs.log("UserLocVar = " + UserLoc );
gs.log("producer.location = " + producer.location );
gs.log("current.assignment_group= " + current.assignment_group );


In the log, it appears the current.assignment_group is not the "SN_Shiftwise_ServiceDesk" group. That sys_id is for the group that is set based on the assignment lookup rule:



find_real_file.png



I was hoping the business rule would override the assignment data lookup rule?