Skip to main content

Data & Intelligence

Coveo: How to fix ContentDocumentLink requires a filter by a single Id

SEO Basics for Developers
Data Intelligence - The Future of Big Data
The Future of Big Data

With some guidance, you can craft a data platform that is right for your organization’s needs and gets the most return from your data capital.

Get the Guide

While crawling object ContentDodumentLink from Salesforce you might come across this issue which is a SOQL limitation on ContentDocumentLink object. the exact error from Coveo Source activity log looks like this:

Implementation restriction: ContentDocumentLink requires a filter by a single Id on ContentDocumentId or LinkedEntityId using the equals operator or multiple Id’s using the IN operator. (MALFORMED_QUERY) -> Failed to GET resource at ‘https://org-url/services/data/v51.0/query/01g79000003Bd2sAAC-1’. [BEGIN RESPONSE BODY][{“message”:”Implementation restriction: ContentDocumentLink requires a filter by a single Id on ContentDocumentId or LinkedEntityId using the equals operator or multiple Id’s using the IN operator.”,”errorCode”:”MALFORMED_QUERY”}][END RESPONSE BODY] -> The remote server returned an error: (400) Bad Request.

this can be handled from Coveo admin console Source config, below are the steps to fix this issue:

  1. Open your Salesforce source config popup:
    Picture1
  2. Click on ContentDocumentLink object on the left-hand side and click Conditions button:Picture2
  3. On the next popup, from the first dropdown select ContentDocumentLink ID – Id, from the second select Not equals, and in the input field enter null and LinkedEntityId in (select id from opportunity), where you can replace Opportunity with any other object your ContentDocumentLink is linked to, this will be included in the SOQL condition which will be according to the SOQL limitation, here is how the final query looks like:

    select Id,SystemModStamp,ContentDocument.CreatedDate, ContentDocument.Id,ContentDocument.LastModifiedDate,ContentDocument.SystemModStamp,ContentDocument.LatestPublishedVersion.CreatedDate,ContentDocument.LatestPublishedVersion.Id,ContentDocument.LatestPublishedVersion.LastModifiedDate,ContentDocument.LatestPublishedVersion.SystemModStamp,ContentDocument.LatestPublishedVersion.Title,ContentDocument.LatestPublishedVersion.VersionData from ContentDocumentLink where Id != null and LinkedEntityId in (select id from opportunity) order by Id desc

    To save the changes click on the + button than click Apply changes at the bottom and Save and rebuild source or Save:
    Picture3

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Rohit Patidar

Rohit is a Technical Consultant at Perficient Inc. With over 4 years of expertise in Java, Angular, and Coveo Development. He enjoys exploring new adventurous places and is a traveler.

More from this Author

Follow Us