- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2024 09:21 AM
We have a group defined that contains users who can approve the purchase of certain devices. The catalog item uses the requesting users organization value (from user record) to further filter the group members.
The Group Members variable is a reference type defined to pull from sys_user_grmember:
I see the following after selecting an Organization:
The number of records getting listed in Group Members is correct but I cannot figure out how to get the user name to display.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2024 11:04 AM - edited 09-26-2024 11:07 AM
A reference variable on the sys_user_grmember table is going to select a record on this table - which is just the user and group relationship. You can change the Display column, but that will affect every appearance of the group member table system-wide, so you really don't want to do this as showing the value of the user column will not make sense outside of this reference variable. What you really want to do is make this a reference to the sys_user table, then you will be selecting an actual user record which will display correctly, and you will be able to use the value in an approval, etc. - something you will not be able to do with a group member table record.
To filter the records to only show users who are members of a certain group, and your organization variable you will need a reference qualifier that looks more like this:
Where groupUtils (or whatever you want to name it) is the name of a Script Include, and getGrpMbr a function, passing in the name of a group. If your organization variable is a reference, and the u_organization field on your user table is a reference, there's no need to dot-walk to name on each in the qualifier. The Script Include will look like this:
var groupUtils = Class.create();
groupUtils.prototype = {
initialize: function() {
},
getGrpMbr : function(grpname){
var usrArr = [];
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.name', grpname)
grp.query();
while (grp.next()) {
usrArr.push(grp.user.toString());
}
return 'sys_idIN' + usrArr.join(',');
},
type: 'groupUtils'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 04:54 AM
Hey , I tried doing something similar but I imagine there may be some slight differences that I am not aware of.
I am pulling from a group table trying to populate the user table based on which group is selected.
Here is my reference qualifier:
javascript: new groupUtils().getGrpMbr() '^group=' + current.variables.existing_assignment_group_name;
I used the same script include you stated in previous. But I am still not populating existing member equal to the group selected.
Can you please assist?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 05:16 AM
You need to concatenate the group, so yours would be
javascript: new groupUtils().getGrpMbr() + '^group=' + current.variables.existing_assignment_group_name;
Unless it makes more sense to pass the selected group to the Script Include to use in the GlideRecord, then you would use
javascript: new groupUtils().getGrpMbr(current.variables.existing_assignment_group_name);
then change the Script Include addQuery to 'group' instead of 'group.name', assuming the existing_assignment_group_name variable is a reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 05:31 AM
Neither one of those work for me.
This the latter one I tried.
The table I am populating members are here, it is a list collector field because I want to make sure they are read only and visible on the form.
and the script include:
var groupUtils = Class.create();
groupUtils.prototype = {
initialize: function() {},
getGrpMbr: function(group) {
var usrArr = [];
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('group.', grpname)
grp.query();
while (grp.next()) {
usrArr.push(grp.user.toString());
}
return 'sys_idIN' + usrArr.join(',');
},
type: 'groupUtils'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 05:37 AM
FYI, I removed the . after group lol. I noticed after I pressed send.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 05:46 AM
I also changed this line
..('group', group);
The list collector field is now showing blank. Probably need one more tweak.
Before the whole list was showing, now there is not any names showing.
almost there hahah