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 07:03 AM
Did you try script I shared?
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 07:32 AM
I tried the solution of changing the spelling, but it is still the same. It's not working on cancel state

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2023 07:36 AM
Please check in the IncidentState script include if the value of your cancelled state matches the cancelled state value in the script.
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-30-2023 08:05 AM
I tried everything, i made the values of incident_State and state for cancelled field same to be in sync. But it's not working so I raised a case with servicenow support. Thnaks for helping me on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2023 01:04 AM
I just checked the oob script include "IncidentStateSNC" in dev and sandbox. In this value of both closed and cancelled state is set as "7". But in oob instances i checked value of canceled state is set at '8' in script include, But the script is set at read only so I can't edit it. I guess that is causing the issue? Any suggestion on how to fix it