Skip to main content

When trying to get ContentDocumentLink records with the following query example: 

SELECT * FROM ContentDocumentLink 

 Salesforce returns the following error: 

MALFORMED_QUERY: Implementation restriction: ContentDocumentLink requires a filter by a single Id on ContentDocumentId or LinkedEntityId using the equals operator or multiple Ids using the IN operator. 

In this article, our ODBC Driver for Salesforce is used as an example to execute that query and display what Salesforce returns. 

 

 

This is a Salesforce limitation for the Salesforce user running that query when it is not filtering the records using either ContentDocumentId or LinkedEntityId fields. 

However, there is a way that you can query that object without needing a filter in either of these two fields. To do so, you need to enable Query All Files permission.  

Steps to enable that permission for the user: 

  1. Go to Setup and search Permission Sets

 

  1. Click New and enter the required information for your permission set. 

Here is what is used for this example: 

 

 

  1. Click Save and then navigate to App Permissions. 

 

 

  1. Click the Edit button and navigate to Query All Files permission which you need to enable. 

 

 

 

 

  1. Save the change. 

  1. Go to Manage Assignments

 

 

  1. Click on Add Assignment and choose the user trying to query ContentDocumentLink, then click Assign

 

 

 

 

Now you should be able to query ContentDocumentLink without needing to filter out the records.  

Here is the same query executed using our ODBC Driver for Salesforce after this change: 

 

 

 

 

 

Be the first to reply!