Question on reference qualifier

Mani60
Tera Contributor

Hi All,

 

We have one field in change module form 'u_peer_approver', we are using group member as an reference for that field in configuration dictionary. But while using this we are getting multiple users records when we type any user name in the peer approver field but it should show one one record of the respective user which we are typing or searching for. to resolve this we are using Advanced reference qualifier and we are using below code for that but it is not working for us. Could anyone help me on this.

 

Please find below code which we are using.

 

var uniqueUsers = new Set();
var searchTerm = current.getDisplayValue('u_peer_approver');


var grUser = new GlideRecord('sys_user');
grUser.addQuery('active', true); 
if (searchTerm) {
grUser.addQuery('name', 'CONTAINS', searchTerm); 
}
grUser.query();

while (grUser.next()) {

uniqueUsers.add(grUser.sys_id.toString());
}

  • if (uniqueUsers.size > 0) {
    answer = 'sys_idIN' + Array.from(uniqueUsers).join(',');
    } else {
    answer = 'sys_idIN';
    }
6 REPLIES 6

Brad Bowman
Kilo Patron
Kilo Patron

Using the sys_user_grmember table, you are going to see one record for every group that the user is a member of.  The reference table for this field should be sys_user, then you can add a qualifier to only show members of the assignment group or whatever if you don't want to see all users.

@Brad Bowman  while searching any user name in peer approval field at that time I'm getting same user name with multiple records. but here I should get name in single record, so could you please help me on this.

Did you change the Reference table to sys_user as I suggested?

BradBowman_0-1731673418939.png

 

@Brad I had tried using the reference user table, and it works, but it is for an old ticket where the peer approval value gets erased. Thats why we were trying this reference qualifier, but even that code is not working.