0

We are redesigning our role hierarchy and add new roles. We are thinking of testing this automatically. We are thinking of building an apex class which can login as a user in all roles and do a soql query on leads, accounts and contacts and other objects. We want to populate this data in a custom object. This way we can make sure once we complete the role hierarchy we can ensure everything is good.

Is there a way in an apex class i can query role hierarchy from top and get an user and do a soql count for each object? We are trying to simulate one user per role and check data access.

1
  • 1
    The only way would be using runAs during a test method.
    – Eric
    Aug 21, 2017 at 23:27

1 Answer 1

0

I confirmed that this can only be done using test class with run as method. We have to use seealldata=true attribute to enable the test class to access all data in the org. From a best practice standpoint, you should not use seealldata parameter but in this situation as this is one utility class, it is fine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .