- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2016 05:50 AM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2016 06:33 AM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2016 06:28 AM
OnLoad CS script should hide label, but have never done it with roles, but should be a simple if statement. Sure they're other ways, but this has worked for me in the paste.
function onLoad() {
//Type appropriate comment here, and begin script below
$('label_IO:5bd38a476f6d1280e5b40edeae3ee4b2').hide(); //Replace this with the sys_id of the label you created.
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2016 06:38 AM
Just a warning, I would be really careful with this approach of of grabbing dom elements by their IDs. There's no guarantee that ServiceNow won't change the way this page renders in future releases and you can't target that element the same way. You should stick to using g_form methods if possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2016 06:43 AM
Hi Brad,
I don't think g_form.setDisplay works on label elements (not in my experience anyway!)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2016 06:43 AM
I tried Brad, I tried so hard, but no worky.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2016 06:46 AM
I actually just tested in a Fuji instance and it works fine