
- 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 06:36 AM
@M_iA setDisplay() can only be used to hide a field on the form. It can't be used to hide a variable set.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2024 07:29 AM
As per the above, I also tried this at the individual field level. Have also tried with setVisible().

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2024 07:32 AM - edited ‎08-29-2024 07:32 AM
@M_iA Is your field a mandatory field on the form? If yes then you can't hide a mandatory field on the form either using a client script or a UI Policy. Here is the evidence.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2024 07:38 AM
No, none of the fields are mandatory