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 hide form header UI action?

Community Alums
Not applicable

Hi Team,

I have couple of "form button" UI actions on the form. All are displayed on both the top form header and bottom of the form.

find_real_file.png

I need to hide only on the form header not in the bottom. How can we achieve this? 

I tried this article https://servicenowguru.com/scripting/client-scripts-scripting/removing-form-buttons/ but it didn't work.

What i need to use exactly here, i used my UI action action_name. Can anyone help me on the same.

find_real_file.png

4 REPLIES 4

Shruti
Mega Sage
Mega Sage

Hi,

Use below onLoad Client script 

function onLoad() {
var items = $$('BUTTON').each(function(item) {
if (item.id == 'sysverb_update') {
item.hide();
throw $break;
}
});

var items1 = $$('BUTTON').each(function(item1) {
if (item1.id == 'resolve_incident') {
item1.hide();
throw $break;
}
});
var items2 = $$('BUTTON').each(function(item2) {
if (item2.id == 'sysverb_delete') {
item2.hide();
throw $break;
}
});
}

I don't think this solution is still valid in more recent SN versions, since I am getting the error message "TypeError: $$ is not a function". Not useful anymore.

CristianCiotes_0-1667450471162.png

 

SNOW BOT
Tera Contributor

Hello Sirraj,

 

As per your requirements, we can hide the header form buttons by creating a UI macro and a UI formatter.

 

1) First create a UI Macro :

PrinceArora_0-1667452373473.png

 

2) Create a UI formatter in sys_ui_formatter table and mention the name of macro in the formatter as highlighted below:

PrinceArora_1-1667452498844.png

 

3) Add this formatter in the form view wherever you want to hide the Actions.

 

I hope this will work.

Please mark the answer as helpful if it works for you 🙂

 

 

 

 

 

CrisCho
Tera Contributor

Hello Prince Arora, thank you for this useful suggestion. It works like a charm 😍
For my exercise, I hid the <span> of class="ui_action_container_primary", that contains ALL buttons in the form's header.

 

<style>
    .ui_action_container_primary {visibility: hidden}
</style>

 

Note: it looks like {display: none} doesn't really work with jelly. Hiding the <span> tag with class .navbar-right looks even better.

hidding_buttons.png