Hide/visible ui action from ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 07:21 AM
I have a ui action in which for one of the if condition I need to hide other ui action button else it should be visible.
Can we do it , if not is there any alternative idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 07:36 AM
Hi @XYD23,
You can set the flag true/false based on on-click of UI action and use that flag to show/hide the another UI action.
If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers! 👍🏻
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 07:39 AM
Can you provide me an example?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 08:21 AM - edited 02-02-2024 08:22 AM
Hello XYD23,
For the UI action button you want to hide:
code
// Display condition script to hide the UI action button
// This script will evaluate to true unless the second UI action button is clicked
true;
For the second UI action button, write a script to set a flag or condition that will cause the first UI action button to be hidden:
code
(function() {
// Set a flag or condition to hide the first UI action button
var hideFirstButton = true;
// Get the name of the first UI action button you want to hide
var firstButtonName = 'first_button_name';
// Set the display condition for the first UI action button based on the flag
if (hideFirstButton) {
// Hide the first UI action button
g_ui_actions.hideAction(firstButtonName);
}
})();
In this script:
g_ui_actions.hideAction(actionName) is a ServiceNow function used to hide a UI action button by its name.
Ensure that you replace 'first_button_name' with the actual name of the UI action button you want to hide. When the second UI action button is clicked, it will execute the script to set the display condition of the first UI action button to false, effectively hiding it.
Please mark helpful if my reply helped you