1

I have the following SOQL query:

SELECT Id, Name, Format, FolderName, LastModifiedDate
FROM Report
ORDER BY FolderName, Name

Which I am executing using this endpoint of the REST API:

/services/data/v35.0/query

Which works fine, except that it returns reports that the current user does not have access to.
How can I limit the results of this query to only include the reports that the user has access to?

The documentation mentions the UserRecordAccess object and how it can be used as a foreign key in your SOQL queries, and includes this example:

SELECT Id, Name, UserRecordAccess.HasReadAccess
FROM Account

This however does not appear to work for Reports, as this query:

SELECT Id, Name, UserRecordAccess.HasReadAccess
FROM Report

Yields the following error:

SELECT Id, Name, UserRecordAccess.HasReadAccess
                 ^
ERROR at Row:1:Column:18
Didn't understand relationship 'UserRecordAccess' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

1 Answer 1

1

The UserRecordAccess for reports can be accessed from the object itself. Try the following SOQL:

SELECT RecordId, HasReadAccess FROM UserRecordAccess WHERE UserId = '00524000001O6ME' AND RecordId = '00O24000004DCbL'

Above, the RecordId is the Report Id.

You must do this for a particular record or group of records (the report) and a particular user.

1
  • Thanks @fred unfortunately I don't think this is an option because (1) it would require multiple queries - one to fetch the list of reports and one to check the access (2) queries to the UserRecordAccess object are limited to 200 RecordIds and it's not uncommon for users to have thousands of reports Nov 11, 2015 at 15:03

You must log in to answer this question.

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