Hiding Labels by a UI Policy

dmullinax
Mega Guru

We have in a variable set a variable of type "formatter."
find_real_file.png

We have several other departments that use this application, but this one department in particular wants to hide this option.
find_real_file.png

Note our business owner wanted the first one hidden as well, but this one was generated automatically by the system.
"When there are 2 or more checkboxes on a Catalog Item / Order Guide, a label named "Options" appears on top of the checkboxes."  https://hi.service-now.com/kb_view.do?sysparm_article=KB0679539

I would like to hide this one as well, but going back to the second one it is defined in the variable set.

Anyways, I try to hide this in a UI Policy.  When I try to define this in a UI Policy action, the variable name does not show up in the "Variable name" drop-down.  As you can see, there is no "formatter" or the name I gave it from the first screen shot.
find_real_file.png

How do I hide these labels?

1 ACCEPTED SOLUTION

dmullinax
Mega Guru

I finally found a solution, and leaving this here for the next developer who needs it.

In the Catalog UI Policy.  In the script tab, use this code...

var doc = this.document ? this.document : document;
var x = doc.getElementsByTagName("label");

for(var i = 0; i < x.length; i++){
    if(x[i].textContent == "Options"){
    x[i].style.display = "none";
    }
}

I even found ways to format the margins, set text color, etc. using JavaScript.

View solution in original post

5 REPLIES 5

The SN Nerd
Giga Sage
Giga Sage

If you put a label above them it won't show Options. You could try make the label empty or so it 'appears' empty.

Otherwise, there is no configuration mechanism to hide them.


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

On second thoughts, you could create the label and then you would be able to hide the label.


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Willem
Giga Sage
Giga Sage

Hi,

The value highlighted in your 1st screenshot is a Container split. Which is not the label.

From your screenshot of the drop down I see "options_label" and "options_label1" try and hide those with UI Policy.

I created a UI Action for "options_label" and "options_label1", and tested the settings.
find_real_file.png

options_label must be a container split as well.
find_real_file.png

Toggling the action hides all of the variables.
find_real_file.png

options_label1 doesn't seem to do anything when I active it.