How to set Incident Assignment Group based on inbound email body

Demetrius Purn1
Kilo Contributor

Hello, 

 

I am looking for a little assistance. I have a requirement to assign incidents to specifc groups based on a segment of the email boday.  I am looking to queue of "VM Queue" and based on the following value assign it to the right group. So here I need Support CTR to go to our Level 2 support. 

 

I have some instances where it may show as "VM Queue: Agility P3" and I need that to go to your Agility team. I have started to alter our current code below, but I am not sure if I am on the right track. 

 

Tenant: xxxxxxxxxxx
Channel: Support Center/xxxxxxxxxxx
Queue: Support Center/xxxxxxxxxxxxxxxx
VM Queue: Support CTR (VM)/xxxxxxxxxxxxxx

 

current.caller_id = gs.getUserID();
current.u_affected_user = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;
current.description = email.body_text;
current.contact_type = 'self-service';
    
if (email.body.VM_Queue("Support CTR") == 0 ) {
    current.assignment_group = "dbf938c8dbbb6010bc653ec8f4961918"; //IT Support Services - Tier 2

1 ACCEPTED SOLUTION

Tony Chatfield1
Kilo Patron

Hi, if the attached example is correct then ServiceNow should have parsed the name: value pairs in your email to variables
Setting field values from the email body (servicenow.com)
and so you should be able to test the variable directly, perhaps something like

if (email.body.VM_Queue.indexOf('Support CTR') > -1 ) {
// it exists so do something
}

Otherwise if testing the body text I would use something like

if(email.body.indexOf('VM_Queue: Support CTR ') > -1)) {
// it exists so do something
}

If unsure or not seeing expected results I would start by adding some logging\debugging to validate the  data that you do have.

 

View solution in original post

1 REPLY 1

Tony Chatfield1
Kilo Patron

Hi, if the attached example is correct then ServiceNow should have parsed the name: value pairs in your email to variables
Setting field values from the email body (servicenow.com)
and so you should be able to test the variable directly, perhaps something like

if (email.body.VM_Queue.indexOf('Support CTR') > -1 ) {
// it exists so do something
}

Otherwise if testing the body text I would use something like

if(email.body.indexOf('VM_Queue: Support CTR ') > -1)) {
// it exists so do something
}

If unsure or not seeing expected results I would start by adding some logging\debugging to validate the  data that you do have.