- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-29-2018 10:53 AM
I have a choice list which is populated by a reference field, which has quite a lot of options.
I would like to be able to reduce the number of options based on the group membership of the logged in user.
Ex:
If I have 10 values populating this choice list, and a user who is a member of group X selects the dropdown, they will only see the first 5.
A user who is a member of group Y will only see the last 5 options.
A user who is a member of both groups will see all 10 options.
I believe I will need to use an On Load client script, but have not found a way to query for a group membership of the current user, and restrict (or show) the options accordingly.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-29-2018 12:58 PM
It will allow multiple group member values. This can be achieved.
g_scratchpad.memberCapex = true;
g_scratchpad.memberAdmin = true;
I haven't used the scratchpad much yet, am I able to define multiple results? In the BR you referred to g_scratchpad.member but the Client Script if statment just used g_scratchpad.-- Sorry for the typo it should be g_scratchpad.memberCapex = true; in the client script too
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-29-2018 11:11 AM
Try this client script:
function onLoad()
{
var checkRole = g_user.hasRole('USER_ROLE_HERE');
var choices = g_form.getValue('CHOICE_LIST_NAME');
if (checkRole == true)
{
g_form.removeOption('choices', 'VALUE_TO_REMOVE');
g_form.removeOption('choices', 'VALUE_TO_REMOVE_2');
g_form.removeOption('choices', 'VALUE_TO_REMOVE_3');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-29-2018 12:47 PM
Found that the following line doesn't really do anything:
var choices = g_form.getValue('CHOICE_LIST_NAME');
I removed it, and changed 'choices' of the script to the name of the field on my form, using the sysID of the values. They were removed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-29-2018 12:01 PM
You would require a Display Business rule to store group membership of current logged in user value(using scratchpad value) and use that scratchpad value in your onLoad Client script.
Your script for Display BR should be something like this.
// Add your code here
if(gs.getUser().isMemberOf('Capex Approvers')||gs.getUser().isMemberOf('Technology Time Management Admin')){
g_scratchpad.member = true;
}
else{
g_scratchpad.member = false;
And OnLoad client script:
if (g_scratchpad== true)
{
g_form.removeOption('choices', 'VALUE_TO_REMOVE');
g_form.removeOption('choices', 'VALUE_TO_REMOVE_2');
g_form.removeOption('choices', 'VALUE_TO_REMOVE_3');
}
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-29-2018 12:54 PM
Hi Prateek,
I haven't used the scratchpad much yet, am I able to define multiple results? In the BR you referred to g_scratchpad.member but the Client Script if statment just used g_scratchpad.
Am I able to define multiple results on the scratchpad, such as:
g_scratchpad.memberCapex = true;
g_scratchpad.memberAdmin = true;
Then call those results in separate IF statements on the client script?
I'm still a bit hung up on how to deal with the scenario where a user is a member of both groups, and as a result shouldn't lose any options.
I'm thinking a nested IF statement might do the trick if the scratchpad will let me pass multiple group member results at the same time.