Email Routing Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 05:03 AM
In email routing rule if the subject is xyz then it will assign to 'A' assignment group other wise it will assign to 'B' assignment group. How i will write the script.
Please try to write the full code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 05:08 AM
Hi Dasarathi,
It can be simply as below.
if(email.subject.indexOf('xyz')>-1)
{
current.assignment_group.setDisplayValue('A');
}
else
{
current.assignment_group.setDisplayValue('b');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 09:07 AM
Try with assignment rules / Data lookup as well. No code is required.
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 09:00 PM
HI @Dasarathi Maha1 ,
I trust you are doing great,
Here's an example script that you can adapt for your needs:
(function runAction(current, email, email_action, event) {
// Define the assignment groups
var groupA = 'sys_id_of_group_A'; // Replace with the sys_id of Group A
var groupB = 'sys_id_of_group_B'; // Replace with the sys_id of Group B
// Check if the subject of the email is 'xyz'
if (email.subject == 'xyz') {
current.assignment_group = groupA; // Assign to Group A
} else {
current.assignment_group = groupB; // Assign to Group B
}
// Update the ticket
current.update();
})(current, email, email_action, event);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi