Search code examples
dynamics-crmcrmmicrosoft-dynamicsdynamics-crm-2016

How to fetch list of documents related to the entity record using CRM APIs?


Following is the exact scenario in our CRM implementation.

We have created a few custom entities, and enabled "Document Management" for them. Now, we need to get list of all documents (with their full URIs) for each entity record using CRM REST APIs.

I tried to look into the entities, but not sure which entity to query in order to get list of documents (and their URIs) associated with an entity record.

Our documents are getting stored over document library in the SharePoint site.

Could anyone please suggest here?

Thanks


Solution

  • Query the SharePointDocumentLocation entity where the regardingobjectid would be the id of the record you want to fetch the document locations for.

    Use the SiteCollectionId property and query SharePointSite entity to get the matching site and construct the url by appending the AbsoluteUrl property of the SharePointSite entity with the RelativeUrl property of the document location entity.