setting incident to active false

Rahul Raja Sami
Tera Guru

Hi I have created a BR on request table, where it checks whether its parent is empty or not.

if not empty then it glide incident table and check for the concerned parent incident and sets it state to request created.
upto this is fine, but I want to set the incident active to false along with its state.

var gr = new GlideRecord('incident');
	gr.addQuery('sys_id',current.parent);
	
	gr.query();
	if(gr.next()){
		gr.state = '9';
		gr.active = false;
gr.work_notes='Incident converted to request \n Kindly access Request from Related List';
		gr.update();
	}

this is changing the state but not setting the active to false.
what to do?

1 ACCEPTED SOLUTION

When I tested this and got it to work, I did the condition on the first tab..."when to run" via the GUI, not on the advanced tab. The advanced tab condition is still "current.incident_state != IncidentState.CLOSED && current.incident_state != IncidentState.CANCELED"

jMarshalatuLe_0-1684947023475.png

^^ I already deleted the custom state in my PDI before I took this screener, but I did this with a custom state of "Request created"

View solution in original post

29 REPLIES 29

Steven Parker
Giga Sage

There is already a Business Rule that makes Incidents inactive that you could just add an additional condition to:

The Business Rule is "mark_closed" on the Incident table.  You could just add another state to the condition and it should run and make the Incident inactive when the state changes to "Request created".

Syntax may need to be adjusted in the below code...just providing an example of what it could look like.

current.incident_state == IncidentState.CLOSED || current.incident_state == IncidentState.CANCELED || current.incident_state == IncidentState.REQUEST_CREATED

 

StevenParker_0-1684937703762.png

 


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

I have tried the same but didn't work

Are you treating "Request Created" the same as "Resolved"?  I've noticed in my personal dev instance that you cannot just make an Incident inactive.  It's needs to be resolved, then closed, and then it becomes inactive.

 

So essentially, since Incidents by default stay in the Resolved state for 3 days before they close, could you put it in the Resolved state instead?  You would need to fill in the close code and close notes as well if you did this.  But then it would auto close and become inactive after a few days.


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

no this is a new state I have created. when request is created from the incident form directly then the state changes to request created. (before it used to get canceled and incident becomes inactive). I want to do the same for request created state as well.