Reference Qualifier Unique Values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2019 11:11 AM
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'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2020 03:55 AM
so replicated your structure on my side and your script seems to be working fine.
table fields
list view of table records
script
var gr = new GlideRecord('u_application_database');
gr.addEncodedQuery('u_application=A');
gr.query();
var db = [];
while(gr.next()){
db.push(gr.getDisplayValue('u_database').toString());
}
var arrUtil = new ArrayUtil();
var dbUnique = [];
dbUnique = arrUtil.unique(db);
gs.info('Database rows (unique) == ' + dbUnique);
gs.print(dbUnique);
here is the output of your script executed in the background script executer
NOTE: all fields are string here just for testing purpose
thanks
Hammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2020 10:55 AM
try
db.push(gr.u_database.name.toString());
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 06:12 AM