- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2016 10:55 AM
Is there any way to show/hide UI action conditionally based on client side selected choices?
I have a catalog item where I have a select box variable "Edit fields" with three choices and show 'none' is selected.
I would like to dynamically display the UI Action "Submit Edits" only if the user selects choice 1, 2 or 3 on the "Edit Fields" variable. If the value is none then ui action is hidden.
This is client side and needs to be onChange() so when the user selects a choice (record will not yet be saved) I want to then display the "Submit Edits" UI Action else it should be hidden.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2016 11:06 AM
Hi Erik,
Word of caution from the "old man". UI actions were not intended to be dynamically visible from a client script. Doing so carries risk of the script not working in future releases.
Reference: Technical Best Practices - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2016 10:58 AM
Hi Erik,
The best practice would be to hide this based on UI action condition field but that would not be dynamic as per the use case you mentioned.
The below blog should answer your question.
http://www.servicenowguru.com/scripting/client-scripts-scripting/removing-form-buttons/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2016 11:01 AM
hi
Yes we can do it by UI Policy.
function onCondition() {
gel('ACTION_NAME_OF_UI_ACTION').style.display = 'inline';
}
function onCondition()
{ gel('ACTION_NAME_OF_UI_ACTION').style.display = 'none';
}
Regards,
Harshvardhan
Hit Like/Helpful/Correct if applicable.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2016 11:06 AM
Hi Erik,
Word of caution from the "old man". UI actions were not intended to be dynamically visible from a client script. Doing so carries risk of the script not working in future releases.
Reference: Technical Best Practices - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2016 11:57 AM
Thanks Sensi....!!!