Hide Ui action button on incident form on state change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2023 07:02 AM
We have a UI action button on incident form header called "Resolve Incident". We want to hide that button when State is changed to cancelled. For that I created a on change client script on incident table which is
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Check if the new value is "Cancel"
if (newValue === '9') {
// Hide the UI action button
g_form.setDisplay('d7e9b3701b6433004e9e97d58d4bcbcf', false);
}
}
Now when I go to any active incident and change state to cancel, there is no change on form. Resolve button is still there. Can you guide me on how to achieve this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2023 02:31 AM
Can you help me with UI action condition to achieve that, currently the condition is :
(current.incident_state != IncidentState.CLOSED && current.incident_state != IncidentState.RESOLVED && current.incident_state != IncidentState.Cancelled) && (gs.hasRole("itil") || gs.hasRole("itil_admin") || current.caller_id == gs.getUserID())
The condition is working fine for closed and resolve state but not for cancel state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2023 02:33 AM
you are using wrong spelling
it should be CANCELED
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
‎06-29-2023 06:05 AM
See the screenshot I attached in reply. The spelling in incident_state choice list is "Cancelled" , that's why I used it

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2023 06:10 AM
That makes sense, but it leverages the 'IncidentState' Script include, it's written differently there,
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2023 07:34 AM
It is not working. I think it's not working because in my choice list also the spelling is not what you said but i am not sure