Catalog item reference field shows sysIDs

dev_K
Tera Contributor

Hi All,

 

 

I would like to create a field that shows in the dropdown all the groups that the requester belongs to however

when I test this catalog item I see that the sysIDs of the groups are fetched instead of the names of the groups. How can I fix it?

 

 

dev_K_0-1727420575585.png

 

 

dev_K_1-1727420714757.png

 

Thanks!

 

7 REPLIES 7

Hm, can you maybe post a screenshot? Maybe it's just because I can't paste the query 1:1 here.

I tested it as shown in my screenshot above, and it worked fine.

Just checking: Did my hints help you, or is there anything left to get your solution up and running?

Voona Rohila
Kilo Patron
Kilo Patron

Hi @dev_K 

Changing the display value of Group Member table is not the correct way.

 

You should not be referring your field to group member table, You have to refer to Group Table and write an advanced reference qualifier to call a script include which returns the group sys_id's.

Reference Qualifier:

javascript: new ScriptincludeName().functionName(current.requested_for);

Script Include function :

 getMembers: function(user) {
        var groups = [];
        var grMember = new GlideRecord('sys_user_grmember');
        grMember.addEncodedQuery('user=' + user);
        grMember.addEncodedQuery('group.active=true')
        grMember.query();
        while (grMember.next()) {
            groups.push(grMember.getValue('group'));
        }
        return 'sys_idIN' + groups.toString();

    },

 

 

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP