Inbound Action: create new INC if replying to closed INC

JP-ODU
Tera Guru

Rather than the baseline Inbound Action "Update Incident (BP)" which reopens a Closed Incidents if its replied to with the subject line "please reopen," we'd like any reply to closed incident to result in opening a new incident.

I thought I had the inbound action script sorted out, but trying to test in our DEV instance, however, it doesn't seem to be working for me and I was wondering if anyone could help figure it out?

I inactivated Update Incident (BP), reopening close incidents isn't functionality we want, and I made a new Inbound Action using this script:

find_real_file.png

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

	// Implement email action here
	
		gs.include('validators');
		
		if (current.getTableName() == "incident") {
		
			var gr =current;
			
			if (gr.state ==IncidentState.CLOSED) {
				
			var sg = new GlideRecord('table_name');
			sg.newrecord();
			sg.setValue('short_description',email.subject.toString());
			sg.setValue('description',email.body.toString());
			// set remaining values
			sg.setValue('field_name','set_the value');
			sg.insert();
		} else {
			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();
		}
		
	}


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

But, when I reply to a closed ticket email to test, my Received Mailbox is recording the emails with the following message: "did not create or update incident using current" and no new Incident is opened... are you able to see what I'm doing wrong?

find_real_file.png

Thanks!

8 REPLIES 8

mind pasting code here ?

and a screenshot of how your recreation inbound action is configured

Sure thing, the inbound action settings are:

find_real_file.png

And the script itself is:

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

	// Implement email action here
	
		gs.include('validators');
		
		if (current.getTableName() == "incident") {
		
			var gr =current;
			
			if (gr.state ==IncidentState.CLOSED) {
				
			var sg = new GlideRecord('table_name');
			sg.newrecord();
			sg.setValue('short_description',email.subject.toString());
			sg.setValue('description',email.body.toString());
			// set remaining values
			sg.setValue('field_name','set_the value');
			sg.insert();
		} else {
			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();
		}
		
	}


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

Am I allowed to bump a thread? Still coming up mystified as to why this isn't working, or at least giving a more detailed error message

Neeraj_V
Tera Contributor

Hi we have a similar requirement and stuck at the same process where the inbound says "did not create or update incident using current". Have you been able to find a solution for it. If yes, would mind share it.

Thanks for the help