Reference Qualifier Unique Values

jmillwood
Giga Contributor

Hello Community, 

I have a Catalog item that currently has 3 Lookup Select boxes. The table they reference has 90k records. This is causing a performance issue. I need to convert at least 2 of them to Reference variables. The table that is being referenced has many safe keys to one group name. So for the end users I want them to only see the unique (distinct) Group name. 

Here is the Script Include I've written, but it's not pulling back just the distinct sys_id. What am I missing? 

var CyberarkGroups2 = Class.create();
CyberarkGroups2.prototype = {
initialize: function() {
},
getGrps: function() {
var gr = new GlideRecord('u_cyberark_data_integration1');
gr.addNotNullQuery('u_ad_group');
gr.orderBy('u_ad_group');
gr.query();
var filter='sys_idIN';
while (gr.next()){

filter += gr.sys_id + ','; //Gets all sys_ids for table u_cyberark_data_integration1
}

return filter;

},

type: 'CyberarkGroups2'
};

 

27 REPLIES 27

if you know a valid sys_id in table u_cyberark_data_integration1

var filter='sys_idIN' + 'sys_id';


/*

while (gr.next()){

filter += gr.sys_id + ','; //Gets all sys_ids for table u_cyberark_data_integration1
}

*/

return filter;

It's still returning all, My Reference qual is javascript:CyberarkGroups2();

 

 

var CyberarkGroups2 = Class.create();
CyberarkGroups2.prototype = {
initialize: function() {
},
CyberarkGroups2: function() {
var gr = new GlideRecord('u_cyberark_data_integration1');
gr.addNotNullQuery('u_ad_group');
gr.orderBy('u_ad_group');
gr.query();
//var filter='sys_idIN';
var filter = gr.sys_id = "0018605b13a5a3404de43598d144b08f";
while (gr.next()){

//filter += gr.sys_id + ','; //Gets all sys_ids for table u_cyberark_data_integration1
}

return filter;

},

type: 'CyberarkGroups2'
};

//Please try this

var CyberarkGroups2 = Class.create();
CyberarkGroups2.prototype = {
initialize: function() {
},
CyberarkGroups2: function() {

var filter='sys_idIN' + '0018605b13a5a3404de43598d144b08f';
return filter;

},

type: 'CyberarkGroups2'
};

 

 

It still pulls back all the AD group names, do I need to load them in an Array? this is frustrating....

The data is arranged like this in the table, I need just the distinct AD group names

find_real_file.png