Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Dynamically fill Assignment Group based on Location and group type

envermalsia1
Kilo Contributor

Hello ,

How to auto populate assignment   group dynamically in incident based on user profile?

I will have hundred of locations and for each location I will have several user groups.

My requirement is for example:

I have a user that has location (e.g. Washington). I have user group (Washington IT) that has location covered (Washington) and also group type (incident_it).

I want if user is from Location Washington and incident is related to IT to be assigned to Washington IT group.

I want to create a business rule to fill assignment group based user's location. From location to filter groups that covered that location and have group type 'incident_it'.

Thank you

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Enver,



You can create a BEFORE business rule with script as. You can have the condition filter as well per your req.


(function executeRule(current, previous /*null when async*/) {



// Add your code here


var userLoc = current.caller_id.location;


var gr = new GlideRecord('sys_user_group');


gr.addQuery('PASS LOCATION FEILD COLUMN HERE', userLoc); //Assuming this field is a reference field


gr.addQuery('PASS GROUP TYPE FIELD COLUMN NAME HERE', "CHOICE VALUE");


gr.query();


if(gr.next());


{


current.assignment_group = gr.sys_id;



}




})(current, previous);





Thank you Pradeep,


I tried but for some reason it is not working. Below is the script. User group has a related list with table  Group Location Coverage  [sys_group_covers_location] and then location field on this table is reference to Location table. Please advise.


Thank you


(function executeRule(current, previous /null when async/) {


// Add your code herevar userLoc = current.caller_id.location;var gr = new GlideRecord('sys_user_group');gr.addQuery('sys_group_covers_location.location', userLoc); //This field is a related list on the user groupsgr.addQuery('type', "mission_it");gr.query();if(gr.next());{current.assignment_group = gr.sys_id;


}



})(current, previous);




On Wednesday, October 11, 2017, 4:13:40 PM EDT, pradeepksharma <community-no-reply@servicenow.com> wrote:




|







|


Dynamically fill Assignment Group based on Location and group type



reply from Pradeep Sharma in IT Service Management - View the full discussion



Hello Enver,



 



You can create a BEFORE business rule with script as. You can have the condition filter as well per your req.


(function executeRule(current, previous /null when async/) {



// Add your code here


var userLoc = current.caller_id.location;


var gr = new GlideRecord('sys_user_group');


gr.addQuery('PASS LOCATION FEILD COLUMN HERE', userLoc); //Assuming this field is a reference field


gr.addQuery('PASS GROUP TYPE FIELD COLUMN NAME HERE', "CHOICE VALUE");


gr.query();


if(gr.next());


{


current.assignment_group = gr.sys_id;



}




})(current, previous);






Reply to this message by replying to this email, or go to the message on ServiceNow Community


Start a new discussion in IT Service Management by email or at ServiceNow Community


Following Dynamically fill Assignment Group based on Location and group type in these streams: Inbox




|


This email was sent by ServiceNow Community because you are a registered user. You may unsubscribe instantly from ServiceNow Community, or adjust email frequency in your email preferences







Thank you Pradeep,



I tried but for it is not working. User group has a related list with table Group Location Coverage [sys_group_covers_location] and then location field on this table is referenced to Location table. Please advise.




Thank you



Below is the script that I'm using !.



(function executeRule(current, previous /null when async/) {


// Add your code here


var userLoc = current.caller_id.location;


var gr = new GlideRecord('sys_user_group');


gr.addQuery('sys_group_covers_location.location', userLoc); //This field is a related list on the user groups


gr.addQuery('type', "mission_it");


gr.query();


if(gr.next());


{current.assignment_group = gr.sys_id;


}



})(current, previous);


Thank you Pradeep,



I tried but for it is not working. User group has a related list with table Group Location Coverage [sys_group_covers_location] and then location field on this table is referenced to Location table. Please advise.




Thank you



Below is the script that I'm using !.



(function executeRule(current, previous /null when async/) {


// Add your code here


var userLoc = current.caller_id.location;


var gr = new GlideRecord('sys_user_group');


gr.addQuery('sys_group_covers_location.location', userLoc); //This field is a related list on the user groups


gr.addQuery('type', "mission_it");


gr.query();


if(gr.next());


{current.assignment_group = gr.sys_id;


}



})(current, previous);