- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 06:51 PM
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:
(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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 11:31 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 09:19 AM
Since you are expecting a change to reflect on the client side, you should preferably go for a client script - OnChange type for the field Major incident state. Try this out
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue == '2') {//Mention your major incident 'proposed' state value here
if (!g_user.hasRoleExactly('incident_manager') && !g_user.hasRoleExactly('major_incident_manager')) {
g_form.setValue('major_incident_state', oldValue); //mention your major incident state field name here
g_form.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).');
}
}
}
If you find this helpful, please mark as Correct or Helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 05:18 PM
Thank you I'll give it a try