function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sylvie SerpletSylvie Serplet 

Retrieving LinkedEntityId via SOQL to update a custom field on ContentVersion

Hi All,
I am trying to create an Apex Trigger to update a custom field on Files (ContentVersion object) with the LinkedEntityId (ContentDocumentLink object).
Any idea how to do it?
Thank you in advance for your help.
Sylvie
 
Raj VakatiRaj Vakati
Use this SOQL to retrieve  you need to use where clause 

SELECT ContentDocument.title ,LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId = '069D00000000so2' AND LinkedEntityId = '0D5000000089123'


https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdocumentlink.htm?search_text=LinkedEntityId
Sylvie SerpletSylvie Serplet
Hi Raj,
Thank you for your response. I got the idea. 
What I am trying to achieve is retrieving the ContentDocumentId and the LinkedEntityId from a File in order to update a custom field on the same File. To do so I have to build a query with several levels of parent, child relationships. And I am not sure how Content Document, Content Version and Content Document Link are related to each other in order to build the SOQL. Cannot really find any documentation.
Thank you in advance for your help.
Sylvie