The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Inbound Email Action to Parse Email Body to Search for a User ID and Group

Beto
Mega Guru

I am trying to pull "name" and "group" from an inbound email that gets send from another ticketing system. User ID would be the caller and group is the assignment group. Please see below on the code. I am pulling "User ID" to get the name of the caller. And pulling "Current Assignees:" for assignment group. Currently it is coming out as guest as caller.

var userIdWithExtraChars = bodyVariable.substring(bodyVariable.lastIndexOf(") by") + 11, bodyVariable.lastIndexOf(") by") + 41);

current.caller_id = email.body.user_name;

if (email.body.assignees != undefined)

current.assignment_group.setDisplayValue(email.body.assignees);

Here is the email:

Body

Notification of Work Order Registration

Work Order:PC Not Working
Work Order Number:79032

Additional Comments:

Entered on 10/27/2017 at 20:29:54 PDT (GMT-0700) by Jane Brown

The PC is not working and is plugged in.

Current Assignees: Desktop Support

Customer Information:

User ID:smithj
1 ACCEPTED SOLUTION

Hi Bryant ,


Did you try:


current.caller_id.setDisplayValue(email.body.user_id);



By the way, I have not had luck using spaces in the email body, so for example, "User ID" did not work, but "user_id" did.


In your email, you have User ID with a space.


harel


View solution in original post

7 REPLIES 7

This one worked with some tweaking thanks.



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


current.short_description = email.subject;


current.description = email.body_text;


current.category = "request";


current.incident_state = IncidentState.NEW;


current.notify = 2;


current.contact_type = "email";



if (email.body.user_id != undefined)


current.caller_id.setDisplayValue(email.body.user_id);



if (email.body.assignees != undefined)


current.assignment_group.setDisplayValue(email.body.assignees);



if (email.body.state != undefined)


    current.state = 6;



if (email.importance != undefined) {


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


          current.priority = 1;



current.insert();



}


can we try like,



current.caller_id = email.body_text.user_id;



current.assignment_group.setDisplayValue(email.body_text.current_assignees);


Still not working. I also tried below. I am more concerned about the user id.



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



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


current.short_description = email.subject;


current.description = email.body_text;


current.category = "request";


current.incident_state = IncidentState.NEW;


current.notify = 2;


current.contact_type = "email";



if (email.body_text.user_id != undefined)


current.caller_id = email.body_text.user_id;



if (email.body.assignees != undefined)


current.assignment_group.setDisplayValue(email.body.assignees);



if (email.body.state != undefined)


    current.state = 6;



if (email.importance != undefined) {


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


          current.priority = 1;



current.insert();



}