How to hide form header UI action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2022 01:17 AM
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2022 01:43 AM
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;
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2022 09:41 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2022 10:19 PM
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 :
2) Create a UI formatter in sys_ui_formatter table and mention the name of macro in the formatter as highlighted below:
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 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2022 12:02 AM - edited 11-06-2022 12:57 AM
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.