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.


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. – Pramod Singh Jan 3 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.