Inbound email Action Requested Item Replies creating multiple tickets and not comments

mattmm
Kilo Sage

I have an Inbound email action I’ve created to create Requested items when an email is sent to a particular mailbox  e.g abc123@cba321.com

Target table: sc_req_item

Action Type: Record Action

Active: yes

Stop processing: yes

When to Run

Type: New

Conditions > Recipients contains abc123@cba321.com

Actions

createRequest();
function createRequest() {
   var cart = new Cart();   //calling the cart API
   var item = cart.addItem('<SYSIDOFCATITEM>');   //sys_id of the catalog item I want to fire
   cart.setVariable(item, 'ps_desc', email.body_text);   //sets catalog variable to email's body
     var rc = cart.placeOrder();   //this launches the catalog item, and creates a request object.   rc = the request object
	 updateRITM(rc.sys_id);   //call a function immediately to update the ritm.   This must be a nested function, otherwise inbound actions get weird.
           //also, we're passing the sys_id of the request so we know what RITM to grab.
}
function updateRITM(req){
   var ritm = new GlideRecord('sc_req_item');
   ritm.addQuery('request', req);   //req is what we passed from the previous function. the sys_id of the request.
   ritm.query();
   while (ritm.next()){
       ritm.opened_by = gs.getUserID();          
       ritm.description = "received from: " + email.origemail + "\n\n" + email.body_text;   
	   ritm.short_description = email.subject;
	   ritm.requested_for = ritm.opened_by;
	   ritm.assignment_group = '<SYSIDOFASSIGNMENTGROUP>';
       ritm.update();
   }
}
function copyAttachments(cartItemID, rc) {
	GlideSysAttachment.copy('sys_email', rc, 'sc_cart_item', cartItemID);
}
current.setAbortAction(true);
event.state="stop_processing";

My issue is that A user emails abc123@cba321.com which correctly creates an RITM000111 with the desired info in Short description and Description.

The abc123 team then reply to that user via email, and the user in turn replies back, but the issue is now it creates another RITM000112.

With each subsequent reply to abc123@cba321.com a new ticket is created. I want it to add the new reply as comments to the original RITM not create a new one. How do I achieve this?

I updated the Update Requested Item inbound action with the condition > recipients is abc123@cba321.com and action below, but no luck.

gs.include('validators');

if (current.getTableName() == "sc_req_item") {
	current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
	
	if (gs.hasRole("itil")) {
		if (email.body.assign != undefined)
			current.assigned_to = email.body.assign;
		
		if (email.body.priority != undefined && isNumeric(email.body.priority))
			current.priority = email.body.priority;
	}
		current.update();
}
1 ACCEPTED SOLUTION

Hi Matt,

Why don't you just redirect the PeopleServices@company.com address straight to ServiceNow and then manage the responses from there? That way all information would be captured in ServiceNow and the notifications managed by ServiceNow (these would contain the watermark).

If the fulfiller team is managing their work, and responding to customers directly through the exchange group email then their responses will never be captured by ServiceNow. ServiceNow will also have no way to correlate the customer replies to the original ticket and will therefore see it as a "New" email and create a duplicate ticket. 

Brent

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.

View solution in original post

12 REPLIES 12

The only other thing I can think of would be to only allow the HR team to only reply to the ServiceNow generated tickets (like an intermediatory).

If they only reply to the ServiceNow ticket then their correspondence will still be recorded in the ticket and ServiceNow would handle the notification to the customer.

Hope that makes sense.

Brent

Perfect. Thanks again for leading me on the trail!

Glad we worked it out. Pleasure helping you.