Inbound Action - Re-open Incidents

Edxavier Robert
Mega Sage

Hi, I am currently working on an Inbound Action to allow user re-open incidents by email. So far is working, but I wanted to restrict to only incidents which are not major incidents in 'accepted' or propose state.

 

gs.include('validators');
if (current.getTableName() == "incident") {
		var gr = current;
// Trying to create a condition to restrict the major incident records being open
		if (email.subject.toLowerCase().indexOf("reopen") >= 0 && gr.major_incident_state != 'accepted' || gr.major_incident_state != 'proposed')
gr = new ReOpenIncident().reopen(gr, email) || gr;
							
/* This is working, but its including major incidents records. 
if (email.subject.toLowerCase().indexOf("reopen") >= 0)
		gr = new ReOpenIncident().reopen(gr, email) || gr;
*/	
	gr.update();
}
1 ACCEPTED SOLUTION

Edxavier Robert
Mega Sage

Thanks @Ratnakar7  and @BharathChintala , I was able to figure out the issue. I was adding the condition in the wrong place. That code that I posted was in the action section of the inbound action but I need it into one of the script included which are being call in the script. 

 

In the script above is calling another script include - ReOpenIncident, which will call another script include: 

 

        if (gr.state == IncidentState.RESOLVED&& gr.major_incident_state != 'accepted' && gr.major_incident_state != 'proposed') {
            // If the incident is Resolved
            gr.state = IncidentState.IN_PROGRESS;
            gr.incident_state = IncidentState.IN_PROGRESS;
            //gr.work_notes = gs.getMessage("The caller did not feel that this issue was resolved " + gr.number);
            gr.update();
            return gr;

View solution in original post

5 REPLIES 5

Edxavier Robert
Mega Sage

Thanks @Ratnakar7  and @BharathChintala , I was able to figure out the issue. I was adding the condition in the wrong place. That code that I posted was in the action section of the inbound action but I need it into one of the script included which are being call in the script. 

 

In the script above is calling another script include - ReOpenIncident, which will call another script include: 

 

        if (gr.state == IncidentState.RESOLVED&& gr.major_incident_state != 'accepted' && gr.major_incident_state != 'proposed') {
            // If the incident is Resolved
            gr.state = IncidentState.IN_PROGRESS;
            gr.incident_state = IncidentState.IN_PROGRESS;
            //gr.work_notes = gs.getMessage("The caller did not feel that this issue was resolved " + gr.number);
            gr.update();
            return gr;