Custom Reference field return group members from one group

anfield
Tera Guru

I have a custom reference field where i want to return all the group members from one group (to be able to select one). At the moment it points to sys_user_grmember and it just returns the group name multiple times. I'd rather not customize anything about sys_user_grmember as that is used in other modules. Found the encoded query below to add into the attributes of the reference field, but it doesnt seem to have an affect.

 

Also tried to modify the columns attribute using ref_ac_columns=user, but that do anything either.

 

Encoded query tried:

javascript&colon;var gr = new GlideRecord('sys_user_grmember');gr.addQuery('group',"<group sys id here>");gr.query();var users='';while(gr.next()){users+=gr.user.sys_id + ",";}"sys_idIN" + users;

 

 

1 ACCEPTED SOLUTION

I used a clean PDI to add a field called App Devs on the incident table to only return the users in the Application Development group.

Final outcome after clicking lookup:

drewmasonNR_0-1710990164161.png

Column entry:

drewmasonNR_1-1710990321021.png

Script Includes:

drewmasonNR_2-1710990374548.png

Group:

drewmasonNR_3-1710990490046.png

 

 

View solution in original post

12 REPLIES 12

You are correct. The function name can be anything. I just recommend naming in a way that makes sense so later down the road you know what that function is doing without having to scroll through the scripts.

Brad Bowman
Kilo Patron
Kilo Patron

If you want your reference field to display a list of users, and store the value of the user selected, then the referenced table must be sys_user!  Your reference qualifier would then call a Script Include to do a GlideRecord on sys_user_grmember, returning a list of sys_ids - or you should be able to use your example as the reference qualifier, provided you use an actual group sys_id in quotes and replace &colon; with the colon character.

Thanks. The colon is rendered on the page somehow automatically on this forum. That encoded query looks fine and returns the expected user ids when tested in a fix script. Ive repointed the reference field to user as a tes and added my original query back, it doesnt seem to have any effect on the reference field results though for some reason. It seems to just pull from the reference qual condition drop down

drewmasonNR
Tera Expert

Where are you trying to use this a filter?

Its just a custom reference field on the demand form (dmn_demand)