How to hide buttons on the form?

nthumma
Giga Guru

by default ServiceNow has two set of buttons one set on the top header of the form and one set is bottom of the form. i want to hide bottom set of buttons.

bottom button html code

<button onclick="return gsftSubmit(this);" style="white-space: nowrap" name="not_important" class="form_action_button   action_context btn btn-default" type="submit" id="sysverb_update" value="sysverb_update" gsft_id="42df02e20a0a0b340080e61b551f2909">Save &amp; Exit</button>

top header button html code

<button onclick="return gsftSubmit(this);" style="white-space: nowrap" name="not_important" type="submit" class="form_action_button header   action_context btn btn-default" id="sysverb_update" value="sysverb_update" gsft_id="42df02e20a0a0b340080e61b551f2909">Save &amp; Exit</button>

any thoughts?


CCing

Travis Toulson

Edwin Munoz

8 REPLIES 8

tltoulson
Kilo Sage

Hi srnewbie,



In older versions of ServiceNow you could toggle the glide.ui.buttons_bottom property to false to hide the buttons.   The wiki says this no longer works in UI15 and courtesy of @SNCory on Twitter, it does not appear that there is a native alternative.



This leaves two main approaches:



1.   Use a UI Script to select the specific buttons to hide


2.   Use a Macro + Formatter to inject css which would look like



.form_action_button {


display: none;


}



.form_action_button.header {


display: inline-block;


}



I personally like #2 though it requires more work (create macro, create formatter for each form, add formatter to each form).   Even if you use JS, you are just applying CSS styles in the end anyway so #2 is more direct and will perform better.


Michael Fry1
Kilo Patron

I believe you're referring to UI actions and checking or unchecking the boxes on the UI action control where it's available:


wiki: UI Actions - ServiceNow Wiki


salemsap
Tera Expert

Hi,


The below code is used to hide both top and bottom button based on the name.You can modify this code and archive your requirement.


var items = $$('BUTTON').each(function(item){


if(item.innerHTML.indexOf("Delete") > -1){


item.hide();


}


});


anud
Kilo Contributor

Hi,

 

I have referred to your script but we found that the above script is not working in the Kingston version, any help on this would be appreciable.

 

Thanks

Anupama