Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 04:03 AM
Hello Experts,
I need to create a report based on a scripted filter, based on reference field for one of the tables, I'm using below script-
var SearchRec = Class.create();
SearchRec.prototype = {
initialize: function() {},
findDup: function() {
var dupRecord = [];
var vdrRecords = new GlideAggregate('sn_vdr_tpro_checker');
vdrRecords.addEncodedQuery('u_draft!=cancelled');
vdrRecords.addAggregate('COUNT', 'u_local_party');
vdrRecords.orderBy('u_local_party');
vdrRecords.addHaving('COUNT', '>', 1);
vdrRecords.query();
while (vdrRecords.next()) {
dupRecord.push(vdrRecords.getValue('u_local_party'));
}
return dupRecord;
},
type: 'SearchRec'
};
Could anyone please guide me here, I want only single unique records for each of the u_local_party field the table, currently when we are applying group by using 'u_local_party' we are getting multiple records for single 'u_local_party' field value.
Could anyone please guide me here, I want only single unique records for each of the u_local_party field the table, currently when we are applying group by using 'u_local_party' we are getting multiple records for single 'u_local_party' field value.
All suggestions are welcome
Thank you
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 05:30 AM - edited 10-26-2023 05:39 AM
Hi @Utkarsha ,
var SearchRec = Class.create();
SearchRec.prototype = {
initialize: function() {},
findUniqueRecords: function() {
var uniqueRecordSysIDs = [];
var previousLocalParty = '';
var vdrRecords = new GlideRecord('sn_vdr_tpro_checker');
vdrRecords.addEncodedQuery('u_draft!=cancelled');
vdrRecords.orderBy('u_local_party');
vdrRecords.query();
while (vdrRecords.next()) {
var localParty = vdrRecords.u_local_party.toString();
if (localParty !== previousLocalParty) {
uniqueRecordSysIDs.push(vdrRecords.sys_id.toString());
previousLocalParty = localParty;
}
}
return uniqueRecordSysIDs;
},
type: 'SearchRec'
};
Try above script.
Please mark it as solution proposed and helpful it serves your purpose.
Thanks,
Anand
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 12:08 PM