Inbound Email Actions "Create Incident" Assignment group not populating

Kays
Tera Expert

Hi Everyone

 

I have the following Inbound email Actions "Create Incident" action where i am trying to assign a ticket to whichever assignment group that gets pulled from the inbound email. The script i have changes the mandatory to grey and looks like its trying to reference the assignment group reference field, however its doesn't display the assignment group in the instance, can someone please advise on the corrected code ?

 

Thank you

Sue

 

My code is below:

 

//  Note: current.opened_by is already set to the first UserID that matches the From: email address

 

current.caller_id = gs.getUserID();

current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;

current.short_description = email.subject;

 

//current.category = "inquiry";

current.incident_state = IncidentState.NEW;

//current.notify = 2;

//current.contact_type = "email";

 

if (email.body.assignment_group != undefined)

    current.assignment_group = email.body.assignment_group;

 

if (email.body.description != undefined)

   current.description = email.body_text;

 

if (email.body.contact_type != undefined)

   current.contact_type = email.body.contact_type;

 

if (email.body.category != undefined)

   current.category = email.body.category;

 

if (email.body.subcategory != undefined)

   current.subcategory = email.body.subcategory;

 

if (email.body.priority != undefined) {

   if (email.importance.toLowerCase() == "high") {

        current.impact = 1;

        current.urgency = 1;

   }

}

 

if (current.canCreate())

    current.insert();

 

15 REPLIES 15

// Note: current.opened_by is already set to the first UserID that matches the From: email address

current.caller_id = gs.getUserID();
current.comments = "Received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;
current.incident_state = IncidentState.NEW;

if (email.body.assignment_group != undefined) {
// Assuming assignment_group is a string representing the name of the group
var assignmentGroup = new GlideRecord('sys_user_group');
assignmentGroup.addQuery('name', email.body.assignment_group);
assignmentGroup.query();
if (assignmentGroup.next()) {
current.assignment_group = assignmentGroup.getUniqueValue();
} else {
gs.addErrorMessage("Assignment group not found: " + email.body.assignment_group);
}
}

if (email.body.description != undefined) {
current.description = email.body.description;
}

if (email.body.contact_type != undefined) {
current.contact_type = email.body.contact_type;
}

if (email.body.category != undefined) {
current.category = email.body.category;
}

if (email.body.subcategory != undefined) {
current.subcategory = email.body.subcategory;
}

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

if (current.canCreate()) {
current.insert();
}