As parentId in ContentDocument records is null, i am unable to locate and delete the records associated with Aggreements records. Is there any way to relate records between these two objects without parentId field.

1 Answer 1


ContentDocument records are linked to their parents or share locations (of which there may be more than one) using ContentDocumentLink records. The Id of the parent record is stored in the LinkedEntityId field on ContentDocumentLink.

I suggest reading through the linked document as you try to design your queries, because there are some unusual restrictions on how you query ContentDocumentLink. In particular,

A SOQL query must filter on one of Id, ContentDocumentId, or LinkedEntityId.


You can't filter on the related object fields. For example, you can't filter on the properties of the account to which a file is linked. You can filter on the properties of the file, such as the title field.

  • Thanks David for your response. Will work on the solution provided by you and keep you posted. Commented Jan 3, 2019 at 13:27

You must log in to answer this question.

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