Respecting ACLs in GlideAggregate

barcar
Tera Contributor

I have a ServicePortal widget which calculates a set of filtered record counts using GlideAggregate.

Is there a way, like GlideRecordSecure to make the aggregate respect the ACL on the table and only count records which the logged in user can see? It seems crazy to have to replicate the same ACL logic in the aggregate query filter.

7 REPLIES 7

no, it is not

Kit Cheong
Giga Guru

No, you'll have to use GlideRecordSecure in your widget server script.

var grs = new GlideRecordSecure('your_table');
//your query here
grs.query();
data.count = grs.getRowCount()

Hey Kit,  even with GlideRecordSecure, all records are returned from the query and getRowCount will return the total, including records that are not read-able by the user. The records are only skipped during the .next() iteration if they are not read-able. You would need to add a custom counter like so:

 

var grs = new GlideRecordSecure('your_table');
//your query here
grs.query();
var total = 0;
while (grs.next()){
total++;
}
data.count = total;