2

I'm looking for a way to run a custom report from Apex, but not as currently logged in user, but as some other specific user. The reason is that I need the report to have only the data that is visible to that specific user. I cannot use filters because I can't easily determine if a user sees a specifc record or not. I could fetch UserRecordAccess and get the Ids of the records that the user sees, but I could only provide 20 of them to the report because that's the limit of report filters.

The only workarounds I found are:

  • Scheduling an Apex job as that user and in the job using Reports.ReportManager.runReport and then caching the results into some custom object
  • Using Email Services, because you can specify context user for inbound message handler, and in the handler doing the same as above
  • Adding a custom field(s) to SObject from the report and storing the information about who sees the specific record there
  • Adding a checkbox to SObject and before I run the report, updating the records that the user sees with checkbox as checked, and then filtering the report by that checkbox

But all those methods are not really suitable for my needs because they either require the report to be cached somewhere, and I need it to be available live, or are very clunky. Would you happen to know some other way to accomplish this? Thanks.

1 Answer 1

0

This is not possible for security reason. Run as only available in test class. You can have dash boards configure with running user. You may have analytical snapshot to capture the data

You must log in to answer this question.

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