Auto-populate Assigned To field based on the combination of Assignment Group and Location

Devansh1
Tera Contributor

Auto-populate Assigned To field based on the combination of Assignment Group and Location in incident table.

1 ACCEPTED SOLUTION

Rajdeep Ganguly
Mega Guru


Sure, you can achieve this by creating a Business Rule in ServiceNow. Here are the steps:

1. Navigate to System Definition > Business Rules.
2. Click on New to create a new business rule.
3. Give your business rule a name, for example, "Auto-populate Assigned To".
4. Select the table as "Incident".
5. Set the "When to run" section as follows:
- When: before
- Insert: true
- Update: true
6. In the "Advanced" tab, write a script to auto-populate the "Assigned To" field based on the combination of "Assignment Group" and "Location". Here is a sample script:

javascript
(function executeRule(current, previous /*null when async*/) {
//Query the sys_user_grmember table to find a user based on the assignment group and location
var user = new GlideRecord('sys_user_grmember');
user.addQuery('group', current.assignment_group);
user.query();
if (user.next()) {
var location = new GlideRecord('sys_user');
location.get(user.user);
if (location.location == current.location) {
current.assigned_to = user.user;
}
}
})(current, previous);


7. Click on Submit to save the business rule.

Please note that this is a simple example and might need to be adjusted based on your specific requirements. For example, you might want to add error handling, or handle the case where multiple users match the criteria.


nowKB.com

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/

For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER

View solution in original post

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Devansh1 

 

Best is use the Assignment rule or Look up methods for this, But my point is avoid assigning the record to user directly, as some time user may be OOO or out of shift.

 

As per best practice, we assign incident to group and group manager / queue manager assign to available user. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Rajdeep Ganguly
Mega Guru


Sure, you can achieve this by creating a Business Rule in ServiceNow. Here are the steps:

1. Navigate to System Definition > Business Rules.
2. Click on New to create a new business rule.
3. Give your business rule a name, for example, "Auto-populate Assigned To".
4. Select the table as "Incident".
5. Set the "When to run" section as follows:
- When: before
- Insert: true
- Update: true
6. In the "Advanced" tab, write a script to auto-populate the "Assigned To" field based on the combination of "Assignment Group" and "Location". Here is a sample script:

javascript
(function executeRule(current, previous /*null when async*/) {
//Query the sys_user_grmember table to find a user based on the assignment group and location
var user = new GlideRecord('sys_user_grmember');
user.addQuery('group', current.assignment_group);
user.query();
if (user.next()) {
var location = new GlideRecord('sys_user');
location.get(user.user);
if (location.location == current.location) {
current.assigned_to = user.user;
}
}
})(current, previous);


7. Click on Submit to save the business rule.

Please note that this is a simple example and might need to be adjusted based on your specific requirements. For example, you might want to add error handling, or handle the case where multiple users match the criteria.


nowKB.com

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/

For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER

Amit Verma
Kilo Patron
Kilo Patron

Hi @Devansh1 

 

You can do it via Assignment rules. Refer https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/task-table/c...

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.