Email Routing Rule

Dasarathi Maha1
Tera Contributor

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.

3 REPLIES 3

Jaspal Singh
Mega Patron
Mega Patron

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');

}

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Dasarathi Maha1 

 

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]

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

Amit Gujarathi
Giga Sage
Giga Sage

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