Query to find all ACL that use a specific role?

gjz
Mega Sage

I am trying to find all ACLs that require a specific role, but I don't know where the data is stored.  When I look at the ACL form, the Roles condition uses an embedded list.  Does anyone know where I can find the data to run a query on it?

1 ACCEPTED SOLUTION

Arafath
Tera Guru

Hi @gjz ,

You can find all the acl's that require a specific role by gliding through 'sys_security_acl_role' table.

here is the example script to find all the acl's that needs itil role:

var aclRoles=new GlideRecord('sys_security_acl_role');
aclRoles.addEncodedQuery('sys_user_role.name=itil');
aclRoles.query();

count=0;
while(aclRoles.next()){
	count+=1;
}
gs.log("count of acl's that requires itil rol are : "+count);

 Hope this helps, if the solution worked for you plz Accept the Solution and Mark it as Helpful so it could benefit fellow devs. Thank you!

 

Regards,

Muhammad Arafath

View solution in original post

3 REPLIES 3

Uncle Rob
Kilo Patron

You can create a list report that has related list conditions.  That would help you select ACLs that have a relationship to a role.  HOWEVER sys_security_acl isn't reportable OOB.  You'd need to create an ACL to make that table reportable.
From there, this video can show you how the related list conditions work.
https://youtu.be/gkzKzSXbwk0

In under 5 minutes learn how to report in #ServiceNow when the conditions have to do with records *related* to what you're reporting on? For example, how many Incidents have NO Incident_tasks? ▼▼▼ Expand for loads of helpful links ▼▼▼ Get on my mailing list! http://bit.ly/fedoruk Need passionate &

Arafath
Tera Guru

Hi @gjz ,

You can find all the acl's that require a specific role by gliding through 'sys_security_acl_role' table.

here is the example script to find all the acl's that needs itil role:

var aclRoles=new GlideRecord('sys_security_acl_role');
aclRoles.addEncodedQuery('sys_user_role.name=itil');
aclRoles.query();

count=0;
while(aclRoles.next()){
	count+=1;
}
gs.log("count of acl's that requires itil rol are : "+count);

 Hope this helps, if the solution worked for you plz Accept the Solution and Mark it as Helpful so it could benefit fellow devs. Thank you!

 

Regards,

Muhammad Arafath

Thank you!  I can't believe I didn't think of looking for a table name that would hold the data.  This worked perfectly.