Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to place button on bottom of form and not up top?

Roger11
Giga Guru

We have a form that we want to keep major record functionality buttons up top of the form (and below) but for buttons that have a "process" flavour that only applies to very limited roles we would like to only show the button UNDER the form - is it possible?


Only want to add button down below...hide it up top..

Roger11_0-1702522893844.png

 

1 ACCEPTED SOLUTION

Danish Bhairag2
Tera Sage
14 REPLIES 14

Danish Bhairag2
Tera Sage

Hi @Roger11 ,

 

Please check this link,it has the solution

 

https://www.servicenow.com/community/developer-forum/how-to-hide-ui-action-based-on-field-change-in-...

 

Thanks,

Danish

 

 

 

I seem to have got it working...
Top of form is

Roger11_0-1702527848424.png

and bottom of form is

Roger11_1-1702527871731.png

UI Action is

Roger11_3-1702527952583.png

UI Policy is

Roger11_4-1702528084122.png

Noting that I used "$$('#action_field_name_from action name field from UI action')

...and that a solution should always contain a fully tested and working solution.

 

...edit

Added a try/catch block around the code as it was generating errors on lookups on the main form

Roger11_2-1702531826745.png

Roger11_3-1702531844268.png

 

Danish Bhairag2
Tera Sage

@Roger11 ,

 

U might need to tweak the solution a bit. In ur case just create an on load UI policy without condition n then try if it works for u or not.

 

No need to write script in false condition. Just true condition script will do the trick.

 

Thanks,

Danish

 

how would you write a script to control the visibility of a "top button" vs a "bottom button"?

ah...I see your first post.

1) Create a UI Policy --> Set Condition as field (check_box) is true

 

2) In the Script tab set Run scripts true

 

3) In the if condition write        

 

                  $$('#action_name')[0].hide();     //This will hide the top button

 

                  $$('#action_name')[1].hide();     //This will hide the bottom button as well



4) In the else condition write        

 

                  $$('#action_name')[0].show();     //This will show the top button

 

                  $$('#action_name')[1].show();     //This will show the bottom button as well



 

 

So if I have a UI action

Roger11_0-1702523955835.png

and I create a UI policy (noting BPE suggestion to not do this)

 

Roger11_3-1702524138782.png

It is still showing up on top.

Roger11_4-1702524193019.png

and also if I use the label of the UI policy

Roger11_5-1702524456071.png