How do I use the ACL to control the number of results returned in a list? After applying the ACL the pagination still exists for all records in the table and the total count is still displayed.

tharzarob
Kilo Explorer

I have applied an ACL condition to a list for a table but that limits the results properly but when viewing the list you still see the total results for all items in the table and the pagination is still applied as if all results are returned.   Is there a way to make sure the pagination and total results returned are in sync with the ACL condition?

1 ACCEPTED SOLUTION

jamesjurden
Giga Guru

I have not found a way to remove that message. You can use a Before Business Rule instead. So for whatever table you are limiting the number of records on, for example the Change table, you can create a before business rule on that table and limit it by Role for example. Below is an example script, limiting the list of resulting records to opened_by the logged in user,   where they have the change_user role. You will have to play around with it a bit, and make sure to test against other users.



limitViewByRole();



function limitViewByRole() {


        if (gs.hasRole('change_user') && gs.getSession().isInteractive()) {


                  var u = gs.getUserID();


                  var vc = current.addQuery("opened_by", u);


        }


}


View solution in original post

3 REPLIES 3

Chuck Tomasi
Tera Patron

Hi Robert,



Can you send a screenshot? I suspect something else is at play here. There may be ACLs preventing you from reading records. In which case you get a message about security constraints preventing you from seeing records.



To remove those and get the information to display ONLY the records you have read access to, take a look at Before Query business rules. See section 10 here



Scripting in Business Rules - ServiceNow Wiki


Abhinay Erra
Giga Sage

For some reason, the number of records will not be in sync with total records that your ACL have access to. As chuck mentioned, use before query BR.


jamesjurden
Giga Guru

I have not found a way to remove that message. You can use a Before Business Rule instead. So for whatever table you are limiting the number of records on, for example the Change table, you can create a before business rule on that table and limit it by Role for example. Below is an example script, limiting the list of resulting records to opened_by the logged in user,   where they have the change_user role. You will have to play around with it a bit, and make sure to test against other users.



limitViewByRole();



function limitViewByRole() {


        if (gs.hasRole('change_user') && gs.getSession().isInteractive()) {


                  var u = gs.getUserID();


                  var vc = current.addQuery("opened_by", u);


        }


}