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-26-2023 07:05 AM - edited ‎06-26-2023 07:07 AM
UI Action display conditions are only evaluated on form change. There is no way to change that without reading the form.
You can however re-evaluate the condition before execution, to make sure nothing 'wrong' happens by using property glide.security.strict.actions.
See for you reference this article.
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 07:53 AM
So can we do something like when we save incident form after changing to cancel state then the UI action become hidden?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2023 07:56 AM
Yes, when you save the form gets reloaded. So this means that the conditions of your UI Action will be re-evaluated. So it can be hidden if the conditions evaluate to false.
So based on your initial script the condition would be something like
current.state != 9;
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-28-2023 04:44 AM
We already had a condition in the ui action I mentioned, I added to it the cancel state part :
&& current.incident_state != IncidentState.Cancelled
But it's not working. It is working fine on resolved and closed state but not cancel state. When I move the incident to resolve state or close state the button gets hidden but this is not working on cancel state
(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())