- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2017 07:15 AM
I'm trying to display a variable on catalog view, item view and task view, only if the logged in user is a member of a certain group. We'd like to hide the variable from admins too.
Trying the below script in UI Policy but not having any luck..:(
function onCondition() {
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group', '=', '1a22d5c1130bcf001454b9722244b01d'); //payroll matrix
grp.addQuery('user', g_user.userID);
grp.query();
if(grp.next()){
g_form.setDisplay('ssn', true);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2017 01:34 PM
Thank you Jaspal and David for the replies. I ended up doing a display business rule and an onLoad client script.
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.grp = gs.getUser().isMemberOf('Payroll Matrix');
})(current, previous);
function onLoad() {
if(g_scratchpad.grp == true)
{
g_form.setDisplay('ssn', true);
}
else
{
g_form.setDisplay('ssn', false);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2017 07:20 AM
Hi Andrea,
Did you try using g_form.setVisible() instead of g_form.setDisplay(). Also, you can have a Client script written onLoad() instead of UI policy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2017 01:34 PM
Thank you Jaspal and David for the replies. I ended up doing a display business rule and an onLoad client script.
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.grp = gs.getUser().isMemberOf('Payroll Matrix');
})(current, previous);
function onLoad() {
if(g_scratchpad.grp == true)
{
g_form.setDisplay('ssn', true);
}
else
{
g_form.setDisplay('ssn', false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2017 07:25 AM
HI Andrea,
I think you might have to put this in an onLoad client script, in a UI policy the script section will execute once the conditions have been matched, the script you're adding is the condition itself.