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-30-2023 08:07 AM
I raised a case with servicenow for this, thanks for helping me on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2023 02:15 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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2023 05:36 AM
Try this
(current.incident_state != IncidentState.CLOSED && current.incident_state != IncidentState.RESOLVED && current.incident_state != IncidentState.CANCELED) && (gs.hasRole("itil") || gs.hasRole("itil_admin") || current.caller_id == gs.getUserID())
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-27-2023 10:32 PM
Write a client script add a code
g_form.setDisplay('button_id',false);
Mark helpful.