UI Action condition based on value on form

emyrold
Giga Expert

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.

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

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


View solution in original post

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

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/


Harsh Vardhan
Giga Patron

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.


Chuck Tomasi
Tera Patron

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


Thanks Sensi....!!!