Enable/Disable a button on the form based on a condition

irfanshaik
Tera Contributor

Hi Team,

 

How can i disable a button on a form that i created using UI Action when one of the field's in a form has a certain value. For example - 

 

irfanshaik_0-1707971237486.png


If i want to Disable the button "Email" if "Col1" (col1) has a value of 5 and have it enabled for any other value of "Col1", how can i achieve that.

 

Thanks.

2 ACCEPTED SOLUTIONS

Aman Kumar S
Kilo Patron

Hi @irfanshaik 

You can just put in the condition field in the UI action.

current.getValue("col1") != 5

But remember this is not real time, once you have the value populated on the page load the decision will happen, not in real time ie the value of 5 should be present when the form loads.

Best Regards
Aman Kumar

View solution in original post

Amit Pandey
Kilo Sage

Hi @irfanshaik 

 

Please refer to the below screenshot-

 

AmitPandey_0-1707973554368.png


current.getValue("col1") != '5';

 

Please mark my answer helpful and correct.

 

Regards,

Amit

View solution in original post

6 REPLIES 6

Aman Kumar S
Kilo Patron

Hi @irfanshaik 

You can just put in the condition field in the UI action.

current.getValue("col1") != 5

But remember this is not real time, once you have the value populated on the page load the decision will happen, not in real time ie the value of 5 should be present when the form loads.

Best Regards
Aman Kumar

Thank you. If i wanted it to update in real time, how would i do that please ?

Hi @irfanshaik 

Its not recommended since you will be going to DOM manipulation which is not best practice, but you can give it a go.

Refer to below article:

https://www.servicenow.com/community/in-other-news/how-to-hide-show-an-ui-action-on-field-changes/ba...

 

Best Regards
Aman Kumar

Thanks!