Inbound Email Action how not to show email body in Activity Log

John H1
Tera Guru

I have a request to build an inbound email action to allow HD users to open tickets via email.

They added an additional request to not show the email body in the initial activity log.

All other work should show in the activity log.

2 REPLIES 2

Jim Coyne
Kilo Patron

Instead of using the "current" object in your Inbound Email Action Script field, which in this case would be a new Incident record, you can create a new GlideRecord which would create a new Incident but not automatically link the email to the record.  Something like (not tested):

 

//	Note: current.opened_by is already set to the first UserID that matches the From: email address
var incident = new GlideRecord("incident");
incident.newRecord();
incident.opened_by = current.opened_by;  //get the User ID from current as the work is done automatically for you
incident.caller_id = gs.getUserID();
incident.short_description = email.subject;
incident.category = "inquiry";
incident.incident_state = IncidentState.NEW;
incident.notify = 2;
incident.contact_type = "email";

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

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

if (incident.canCreate())
	incident.insert();

 

Based on the OOTB "Create Incident" Inbound Email Action, replacing "current" with "incident" for most of the lines (except for "incident.opened_by = current.opened_by;").  It will unfortunately skip a number in the counter because "current" gets assigned a new Number.

 

Again, this was NOT tested, but should do the trick.

johnfeist
Mega Sage
Mega Sage

Hi John H1,

 

An alternative approach would be as follows.

 

If all you need to do differently is not include the initial email in the log, after you've done the insert, using the sys_id of your current record, look in sys_journal_field for the element_id that matches your current's sys_id and a value starting with received from.  Having found that record, delete it.  That should leave the initial email in the description but not in the log.  Be sure to test thoroughly to make sure taht there are no unexpected side effects.

 

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster