How to hide/show a UI action button based on change in value of a field on a form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2020 12:31 AM
Hello All,
Is there a way to hide/show UI action button based on change in value of a field on a form?
Sowmya
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2020 12:44 AM
Hi,
UI actions condition are evaluated on form load; so if you want to show/hide UI action on field change; you need to use onchange client script; ensure isolate script is set to false for that client script
you would require dom manipulation for this;
Sample script below:
if(value == 'Yes'){
var items = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('UI Action Title') > -1){
item.hide();
}
});
}
else if(value == 'No'){
var items = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('UI Action Title') > -1){
item.show();
}
});
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
03-12-2020 12:57 AM
Yep, but on client script how can we achieve this? DOM is now not recomended and doesn't work too in Newyork. Alos what do you mean by isolate script is set to false?
Sowmya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2020 01:00 AM
Hi,
check isolate script to false from list layout; other than DOM you cannot achieve this on change show/hide the UI action
screenshot below for isolate script field to false
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader