- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 11:20 PM
Hello Community,
I have a requirement as below :
I wish to hide custom UI action on change record table. Whenever the condition is 'Subject to Gxp == Yes' the ui action must disable/hide.
I have the below code prepared for it :
The issue is it only hides the top button and not the bottom button. I even tried querying the button itself but no luck 😞
Please help me achieve this requirement ...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 11:29 PM
Set the condition in the condition field of the UI Action not via client script. (current.subject_to_gxp == 'No')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 11:27 PM
Hi,
DOM is not recommended practice.
If you still require then ensure Isolate Script field is Set to False for your UI policy
Use this script in Execute if True
Ensure you give the correct action name - I have given test; you give your UI action name
function onCondition() {
$j('[data-action-name=test]').hide();
}
Use this script in Execute if False to show
function onCondition() {
$j('[data-action-name=test]').show();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 11:30 PM
Hi,
Usually UI actions are shown based on condition field
If you wish to show/hide it based on some field change then UI policy is required; but it would require DOM manipulation which is not recommended.
If you wish not to show/hide then ensure you add correct condition in the UI action so that it shows only when that condition evaluates to true
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 11:27 PM
Hello Hritik,
Why you are writing a UI policy to hide the UI action. Instead you can specify the conditions under UI actions only to hide the UI action.
Here in the UI policy script you are using DOM to hide the UI action which is not the best practice and it may vary the results based on the browsers/upgrades.
Hope it helps!!
Please Mark ✅ Correct/helpful, if applicable, Thanks!!
Regards
Sulabh Garg
Regards
Sulabh Garg

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2022 11:27 PM
Why don't you directl pass the condition in the Condition field of the UI Action.
No need of DOM manipulation