- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2021 11:29 AM
Hello,
I have a form the service portal and I need to have a field that show the groups that the current logged in user is a member of. So when a user comes to the form, they will only see groups that they are part of in the dropdown. Should this be a reference field? Pretty sure I need to use a reference qualifier but wasnt able to figure it out. Thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2021 11:56 AM
Hi,
If you are only wanting to allow them to select one option, then yes, reference field to the sys_user_group table would work. You are also correct about needing an advanced reference qualifier which would be:
javascript:"sys_idIN" + gs.getUser().getMyGroups()
No other scripting required 🙂
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2021 11:48 AM
You should create on reference field which will refer to the sys_user_group table.
Then Create one Script include:
Sample code:
var Get_group = Class.create();
Get_group.prototype = {
initialize: function() {
},
getName: function(){
var arr = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user',gs.getUserID());
gr.query();
while(gr.next()){
arr.push(gr.group.toString());
}
return 'sys_idIN'+ arr;
},
type: 'Get_group'
};
Advance Reference Qualifier which you will use like below.
javascript: new Get_group().getName()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2021 11:49 AM
Hi,
If you are only wanting to allow them to select one option, then yes, reference field to the sys_user_group table would work. You are also correct about needing a reference qualifier which would be:
javascript:"sys_idIN" + gs.getUser().getMyGroups().toArray()
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2021 11:56 AM
Hi,
If you are only wanting to allow them to select one option, then yes, reference field to the sys_user_group table would work. You are also correct about needing an advanced reference qualifier which would be:
javascript:"sys_idIN" + gs.getUser().getMyGroups()
No other scripting required 🙂
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2021 11:56 AM
Thanks. I tried it this way and it gave me all of the groups, not just the ones i am a member of.