Can anyone help me with Inbound Email Action ?

Sneha8
Tera Contributor

Hi, I am writing an inbound email action in which if the email has been sent to a particular email address (test@example.com") then the category, sub-category, and assignment group of the incident should get auto-populate according to the script for that email address. But the problem occurring is that if an email is sent to a ServiceNow instance mail address (test@service-now.com) then the category, subcategory, and assignment group of the incident is getting populated of the populated (test@example.com") mail address.

 

Here's my code

current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;
current.description = email.body; // 

current.category = "inquiry";

current.subcategory = "xxx";

current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";
current.watch_list = email.origemail.toString();


if (email.direct.indexOf("test@example.com") >=-1) {
    current.assignment_group.setDisplayValue("sys_id of group");
    current.category = "software";
    current.subcategory = "valence";
    current.watch_list = email.origemail.toString();
    
}


if (email.body.assign != undefined)
    current.assigned_to = email.body.assign;

if (email.importance != undefined) {
    if (email.importance.toLowerCase() == "high") {
        current.impact = 1;
        current.urgency = 1;
    }
}

current.insert();

 

Kindly help me out!

1 REPLY 1

Marcin20
Mega Guru

Hi,

Please could you check this line:

    current.assignment_group.setDisplayValue("sys_id of group");

 

this should be something like:

    var assignment_group = "Support Group 01";  //please put the name of the assignment group to be assigned

    current.assignment_group.setDisplayValue(assignment_group);

or

 var assignment_group_id = "f2ad9e8297b8d11079c130d3f153afd0"; //please put the sys_id of the assignment group to be assigned

  current.assignment_group = assignment_group_id;

 

Best Regards,

Marcin

 

If my answer helped you in any way, please mark this answer as helpful and correct.