How to prevent replies to closed ticket email from adding a comment

Staxed
Giga Guru

From everything I've been able to find, OOB when someone replies to a closed incident email, it should not allow a comment to be made on the incident.

However, in my instance, people can reply to a closed incident email notification and it updates the incident with a comment and also sends both the user and whoever is assigned to the incident an update email.

I've been looking for the solution and I just can't seem to find out what is causing this behavior.  Does anyone have any advice on where I should be looking to prevent the comment from being added to the incident?  I would like the OOB functionality (unless that's changed in Rome?): someone replies to closed notification and it prevents the comment from being added and does not notify the assigned person.

1 ACCEPTED SOLUTION

Put it before the line gr.comments S

o it would be like below format open before gr.comment and close after gr.comment

If(gr.state!=7)

{

The line with gr.comments

}

Please mark answer correct/helpful based on impact

View solution in original post

7 REPLIES 7

Saurav11
Kilo Patron
Kilo Patron

Hello

This is controlled by inbound action named Update incident bp

Just go to that inbound action and before the comment update line write a if logic that gr.state!=7 only then it goes to update incident

Please mark answer correct/helpful based on impact

Would you mind showing where to put that if statement?  I'm very new to both ServiceNow and Javascript...learning as I go.

 

gs.include('validators');

if (current.getTableName() == "incident") {
	
	var gr = current;
	
	if (email.subject.toLowerCase().indexOf("please reopen") >= 0)
		gr = new Incident().reopen(gr, email) || gr;
	
	gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
	
	if (gs.hasRole("itil")) {
		if (email.body.assign != undefined)
			gr.assigned_to = email.body.assign;
		
		if (email.body.priority != undefined && isNumeric(email.body.priority))
			gr.priority = email.body.priority;
	}

	gr.update();
}

Put it before the line gr.comments S

o it would be like below format open before gr.comment and close after gr.comment

If(gr.state!=7)

{

The line with gr.comments

}

Please mark answer correct/helpful based on impact

Like this?

gs.include('validators');

if (current.getTableName() == "incident") {
	
	var gr = current;
	
	if (email.subject.toLowerCase().indexOf("please reopen") >= 0)
		gr = new Incident().reopen(gr, email) || gr;
	
        if (gr.state != 7) { 
	gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
        }
	
	if (gs.hasRole("itil")) {
		if (email.body.assign != undefined)
			gr.assigned_to = email.body.assign;
		
		if (email.body.priority != undefined && isNumeric(email.body.priority))
			gr.priority = email.body.priority;
	}

	gr.update();
}