Inbound email action for reply type

AnandKumar1
Tera Expert

Hi Team,

I have created a inbound email action that will log a new ticket. I have a requirement that if user replies from same original mail thread, email body text should update in additional comments of the already logged ticket.

Please help me to achieve this.

Thanks in advance.

Anand.

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Anand,

 

System will automatically take care of that if you have

1. Inbound of type : Reply

2. Watermark is present on the mail received (MSG....) is the message number at the bottom of the mail that ServiceNow recognizes to categorize it as reply or new or forward mail

3. If above are configured can you share the inbound action script once.

View solution in original post

3 REPLIES 3

Jaspal Singh
Mega Patron
Mega Patron

Hi Anand,

 

System will automatically take care of that if you have

1. Inbound of type : Reply

2. Watermark is present on the mail received (MSG....) is the message number at the bottom of the mail that ServiceNow recognizes to categorize it as reply or new or forward mail

3. If above are configured can you share the inbound action script once.

Hi Jaspal,

 

Thanks for your response. 

hammad ul aziz2
Mega Guru

hi,

I am assuming you're sending an Incident number somewhere in the email body or in the subject of the email.

so once that user reply back to that email you can create an inbound action as shown below

find_real_file.png

as you can see I have added a condition as subject contains incident you can add more condition to specifically trigger this inbound action and not any other inbound action.

lets suppose the subject is something like..

Re: New incident created INC0010017

now in your action script do something like this to extract the incident number from subject to update comments with email body on that specific incident.

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {

	//lets suppose the subject is Re: New incident created INC0010017
	var string =email.subject;
	var number = string.match(/(\binc\S+\b)/ig);
	//above statement will give us array of words starting with inc we will get two words (incident,INC0010017)
	//incident word is on idex 0 and INC0010017 is on index 1 so we will use index one to get incident number
	var incident=new GlideRecord('incident');
	incident.addQuery('number','=','number[1]');
	incident.query();
	if(incident.next())
		{
			incident.comments=email.body;
			incident.update();
		}
	// Implement email action here

})(current, event, email, logger, classifier);

find_real_file.png

 

give a try and mark my answer correct if this sovles your issue or if that helps you please mark my answer as helpful.

 

thanks

hammad ul aziz