Enforcing ACLs with GlideAggregate ( similar to GlideRecordSecure )

mauricio_paloma
Tera Expert

Is there a way to enforce ACLs using GlideAggregate in the same way it is done using GlideRecordSecure?

7 REPLIES 7

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Mauricio,

 

You can use method canCreate()/canWrite()/canRead()/canWrite() to enforce ACL's check. More info here.

https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_ScopedGlideRecordCanCreate

 

Thanks,

Pradeep Sharma

.

Can you show me a way to use GlideAggregate with canRead() in order to get an accurate COUNT ?

Hi Mauricio,

 

Here you go.

var count = new GlideAggregate('u_aggretable'); //Replace u_aggretable with the exact Table Name
count.addAggregate('COUNT');
count.query();
var recount = 0;
if(count.next() && count.canRead())
{
recount = count.getAggregate('COUNT');
gs.addInfoMessage(recount);
}

 

Thanks,

Pradeep Sharma

Hi Pradeep

 

This logic isn't entirely accurate. For example, the CMDB table has many extended tables.  Some of those tables may be accessible and others are not accessible. ie: var count = new GlideAggregate('cmdb_ci')

I would like to get a count of the number of records I do have access to. The logic above assumes access is boolean across all records which is not always the case. 

Do you have another idea?