Business rule for incident state change to Resolve

Javier19
Tera Contributor

Good morning, I need to create a Business rule that prevents incidents to be changed to the "Resolved" state if their previous state was not "In Progress".

In the filter condition I have ticket the Update box, and set "State" with "Changes to" "Resolved". But I would need some help on the code to put in the Advanced tab, could someone please assist with this? Thanks in advance!

1 ACCEPTED SOLUTION

rajneeshbaranwa
Giga Guru

You may use below script to stop update to resolved , if state is anything other than WIP.

(function executeRule(current, previous /*null when async*/) {

	if (!(previous.state) || previous.state != 2)
		{gs.addInfoMessage("Incident can be resolved only if current state is WIP");
			current.setAbortAction(true);}
	// Add your code here

})(current, previous);

View solution in original post

3 REPLIES 3

bammar
Kilo Sage
Kilo Sage

you can use filter- State Changes FROM In Progress & State Changes to Resolved dont believe advanced is necessary here. 

rajneeshbaranwa
Giga Guru

You may use below script to stop update to resolved , if state is anything other than WIP.

(function executeRule(current, previous /*null when async*/) {

	if (!(previous.state) || previous.state != 2)
		{gs.addInfoMessage("Incident can be resolved only if current state is WIP");
			current.setAbortAction(true);}
	// Add your code here

})(current, previous);

Javier19
Tera Contributor

Thank you very much, it worked like charm!