Make UI Action button appear with onclick event?

matthewt
Kilo Contributor

Here is the behavior I want.

1. User clicks checkbox.

2. Button appears (UI action) without updating the form.

Is this possible? If so, how?

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi,



This can be done using a UI Policy. Please follow the steps below to achieve the same:



1) For example I have a UI Action Named "Create Task" on the Incident form which I want to hide based on a checkbox field named "Checked" on the Incident form.



2) So Configure a UI Policy as shown below:



find_real_file.png



find_real_file.png



While Configuring the UI Policy "Make sure the "On load" & "Reverse if false" is checked on the UI Policy form.



In the above script Just rename "hide_check" with your UI Action Name which you want to hide. For example below is my UI Action and my action name is also highlighted below as shown:



find_real_file.png




Result:



I have checked the field "Checked" and then UI Action "Create Task" is visible as shown below:



find_real_file.png



If you uncheck the UI Action does not gets displpayed.



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

11 REPLIES 11

Dave Smith1
ServiceNow Employee
ServiceNow Employee

Matthew Taraschke wrote:



Not trying to be rude... But how do either of your answers help me?


No rudeness detected, but...


  • my second response provided you with an answer (which you reminded: the answer is what you sought)
  • my first response highlighted that requiring two user actions to perform one activity without good reason is considered poor UI design

If you didn't find either my answer nor my caution helpful, then...



My initial thought would have been some client-side scripting: all buttons, links, etc have an ID attribute to uniquely identify them on page, so it's possible to bind a client-side event that makes this button invisible upon loading then reveals it upon a checkbox action.



A preferred way is to create a UI policy (I'd began a proof-of-concept but just seen that someone had beaten me to it - and a good ) that triggered the hide/reveal, rather than client scripting.   UI Policies are generally preferred over pure scripting; in fact, server-side methods are preferred over client-side, but as you wish the response to be dynamic without another round trip it'll have to be something client-side.



However, I was waiting to see how far you'd progressed in your solution first.   Either way, hope you find Sholke's (pretty comprehensive) response helpful.


shloke04
Kilo Patron

Hi,



This can be done using a UI Policy. Please follow the steps below to achieve the same:



1) For example I have a UI Action Named "Create Task" on the Incident form which I want to hide based on a checkbox field named "Checked" on the Incident form.



2) So Configure a UI Policy as shown below:



find_real_file.png



find_real_file.png



While Configuring the UI Policy "Make sure the "On load" & "Reverse if false" is checked on the UI Policy form.



In the above script Just rename "hide_check" with your UI Action Name which you want to hide. For example below is my UI Action and my action name is also highlighted below as shown:



find_real_file.png




Result:



I have checked the field "Checked" and then UI Action "Create Task" is visible as shown below:



find_real_file.png



If you uncheck the UI Action does not gets displpayed.



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

USED THIS AND MY ENTIRE TABLE HANGED, THEN ON DELETING THE UI POLICY, IT IS WORKING.

 

Community Alums
Not applicable

Hi,

 

I have reverse requirement.

like onclicking of button on the incident form,flag should be checked.

could you please help me in that.

Community Alums
Not applicable

Hi,

 

this code is not working as expected.