
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2024 06:26 AM
I have a simple need to only load a variable set if the logged in user has a specific role. However, for some reason which i cant work out, it doesnt run!
function onLoad() {
var hasRole = g_user.hasRole('sn_esm_user_admin');
if (hasRole == true) {
g_form.setDisplay('query_on_behalf_of', true);
} else {
g_form.setDisplay('query_on_behalf_of', false);
}
}
Have tried all of the individual fields as well, but no luck!
Any ideas?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2024 09:27 AM
I scrapped the client script completly and went with this on the individual variables within the variable set:
This worked and for people who want no code, this is the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2024 07:43 AM
Hi @M_iA Have a look at this thread https://www.servicenow.com/community/developer-forum/how-to-hide-variable-set/m-p/1969461#:~:text=Us....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2024 09:27 AM
I scrapped the client script completly and went with this on the individual variables within the variable set:
This worked and for people who want no code, this is the solution