
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2022 07:12 AM
Hello! I need to create a reference field where it shows me the members of a specific group but does not show me the member that is already selected in another field, even if he is a member of the group. Can it be done with a simple Reference Qual with a condition or should I do it with a script? Thank you very much.
Solved! Go to Solution.
- Labels:
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2022 09:19 AM
Hello Rocio,
I think you need a script.
Create a script called (for example) Utils with a method called "getGroupMembers" like the one bellow:
var Utils = Class.create();
Utils.prototype = {
initialize: function() {
},
getGroupMembers: function(group_name, excluded_user){
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", group_name);
gr.addQuery("user", "!=", excluded_user);
gr.query();
var result = [];
while(gr.next()){
result.push(gr.getValue("user"));
}
return "sys_idIN" + result.join(",");
},
type: 'Utils'
};
This method received two parameters:
1) group from which you want to display the members
2) field that contains the user that you don't want to show in the member list
Then, in the reference qualifier of your field that will display the group members, configure an advanced reference qualifier like the following:
javascript: new Utils().getGroupMembers(current.assignment_group, current.user_to_exclude);
(update the parameters of the getGroupMembers method! I made up the assignment_group and user_to_exclude!)
This should do the trick for you!!
Please mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2022 09:19 AM
Hello Rocio,
I think you need a script.
Create a script called (for example) Utils with a method called "getGroupMembers" like the one bellow:
var Utils = Class.create();
Utils.prototype = {
initialize: function() {
},
getGroupMembers: function(group_name, excluded_user){
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", group_name);
gr.addQuery("user", "!=", excluded_user);
gr.query();
var result = [];
while(gr.next()){
result.push(gr.getValue("user"));
}
return "sys_idIN" + result.join(",");
},
type: 'Utils'
};
This method received two parameters:
1) group from which you want to display the members
2) field that contains the user that you don't want to show in the member list
Then, in the reference qualifier of your field that will display the group members, configure an advanced reference qualifier like the following:
javascript: new Utils().getGroupMembers(current.assignment_group, current.user_to_exclude);
(update the parameters of the getGroupMembers method! I made up the assignment_group and user_to_exclude!)
This should do the trick for you!!
Please mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz