Emergency change BR is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
(function executeRule(current, previous /*null when async*/ ) {
var AGMember = false;
var currentUser = gs.getUser();
AGMember = currentUser.isMemberOf(current.assignment_group.getDisplayValue());
if (!(current.requested_by == gs.getUserID() || AGMember || current.opened_by == gs.getUserID()||gs.hasRole('change_manager'))) {
gs.addErrorMessage('should ');
current.setAbortAction(true);
} else {
current.work_notes = ' cancelled.';
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Is BR condition getting satisfied?
The Type = Emergency and State Condition is getting satisfied?
are you saying when CHG is Emergency and you click Cancel then that error comes?
if yes then it means the UI action is not updating and hence BR is not triggering.
Did you check the action name is not used somewhere else?
I couldn't find this OOTB UI action in my instance.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Normal and standard change request it is working as expected....just for Emergency .even if, I'm the opened by ...I should able to cancel the change (working in Normal and Standard).Not in emergency.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
please check my above points.
Did you check who created that UI action?
If it's admin, maint etc then it means it's OOTB
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you’re bumping into the Change State Model guardrails for Emergency changes.
The OOTB Cancel action ultimately calls the ChangeRequestStateModel, which decides if cancel is allowed in the current state/type.
By OR-ing your custom checks with isCancelAvailable() you made the button visible even when the state model will deny the transition for Emergency → hence the server throws “Action not authorized.”
Fix (2 parts)
1) UI Action condition (show only when both: authorized and cancel is allowed)
Replace your condition with AND instead of OR:
(
gs.hasRole('change_manager') ||
gs.getUser().isMemberOf(String(current.assignment_group)) ||
current.opened_by == gs.getUserID() ||
current.requested_by == gs.getUserID()
)
&&
new ChangeFormUI(current).isCancelAvailable();
2) Authorization guard (server-side “Before” BR)
(function executeRule(current, previous) {
var user = gs.getUser();
var isAGMember = !gs.nil(current.assignment_group) && user.isMemberOf(String(current.assignment_group));
var isOpener = current.opened_by == gs.getUserID();
var isRequester = current.requested_by == gs.getUserID();
var isChangeMgr = gs.hasRole('change_manager');
// Only gate by your business rule; the state model will still have the final say
if (!(isOpener || isRequester || isAGMember || isChangeMgr)) {
gs.addErrorMessage('Action not authorized for your role/group/requestor.');
current.setAbortAction(true);
return;
}
// Do NOT force notes or status here. The Cancel UI Action / state model will handle it.
})(current, previous);
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Udhayakumar_30 ,
Please check if any other access restriction when type is emergency change.
Are doing testing for all the change type for same user? There may be access issue.
Thanks,
Bhimashankar H
-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!