The CreatorCon Call for Content is officially open! Get started here.

How do I hide a Catalog Item label?

Shane J
Tera Guru

I can't seem to find either a UI Policy or Client Script that will allow me to hide a Catalog Item label - everything I am seeing is more modifying a label not hiding it.   I am trying to do so by Role.

>Using the 'Read roles' function on the label variable has no effect.

>This doesn't work:

function onLoad() {

var rol = (g_user.hasRoleFromList("bpad,dabi,himc"));

if (rol)

g_form.setVisible('label', 'true');

else

g_form.setVisible('label', 'false');

}

>I tried using different flavors of document.getElementById('4f1faae46f5d9e407c7927ee2c3ee4cd') but that got me nowhere.

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

What is the name of that label variable, and is the name unique compared to all the other variables on the form?



You should be able to use its name like:



g_form.setDisplay('mylabel', false);



23d249016b.png


View solution in original post

12 REPLIES 12

Brad Tilton
ServiceNow Employee
ServiceNow Employee

What exactly do you mean by catalog item label? Could you include a screenshot?


2016_02_19_08_27_54_ServiceNow_Service_Automation.png


Brad Tilton
ServiceNow Employee
ServiceNow Employee

What is the name of that label variable, and is the name unique compared to all the other variables on the form?



You should be able to use its name like:



g_form.setDisplay('mylabel', false);



23d249016b.png


It is, but I couldn't get that to work.   I did get Kyle's solution to work however.



Here's my script:



function onLoad() {


var rol = (g_user.hasRoleFromList("bpad,dabi,himc"));


  if (!rol){


  $('label_IO:4f1faae46f5d9e407c7927ee2c3ee4cd').hide();


  }


}