Business rule not aborting update

Abbottronix
Tera Guru

I'm trying to write a business rule that prevents an incident from being proposed as a major incident if the user lacks MIM roles, but it's not aborting the proposal. This is my condition and code:

 

Abbottronix_0-1732848437290.png

 

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

	var user = gs.getUser();
	
	if (!user.hasRole('incident_manager') || !user.hasRole('major_incident_manager')) {
		gs.addErrorMessage('If you are proposing a Major Incident, you are required to engage the Major Incident Management (MIM) team by PHONE CALL.  Contact details and Escalation Matrix can be found in the Enterprise Service Management Policy and Procedures Manual (ESM PPM).');
		current.setAbortAction(true); 
	}


})(current, previous);

The error message is appearing, but the incident is still getting proposed as a MIM candidate. 

1 ACCEPTED SOLUTION

Sherin Jenifer
Giga Guru

Hi @Abbottronix , as @Runjay Patel  suggested the State will not be updated as Proposed as it will throw Invalid update error. The State Choice list changes to Proposed in the client-side alone, it is not updated in the server-side. If you could Reload form , you can find that the state is not updated.


If you find this helpful, please mark as Correct or Helpful.

View solution in original post

6 REPLIES 6

Runjay Patel
Giga Sage

Hi @Abbottronix ,

 

You mean incident state is getting saved as Proposed although error message appearing? 

if you are getting error message then state will not set to proposed.

 

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @Abbottronix 

If you are using a negative condition, then it should be && instead of ||

Can you try by changing once?

 

Please mark the answer as helpful and correct if helped.

Kind regards,

Ravi Chandra 

 

Sherin Jenifer
Giga Guru

Hi @Abbottronix , as @Runjay Patel  suggested the State will not be updated as Proposed as it will throw Invalid update error. The State Choice list changes to Proposed in the client-side alone, it is not updated in the server-side. If you could Reload form , you can find that the state is not updated.


If you find this helpful, please mark as Correct or Helpful.

You're right, that's what was happening. Is there anyway to make it reload from a business rule so that users won't get confused?