web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Unable to Retrieve Data from SharePoint Document Table via D365 Web API

(1) ShareShare
ReportReport
Posted on by 12

This is the SharePoint document grid in D365.
We have added a custom button to this grid.
When the button is clicked, we want to retrieve the details of the selected SharePoint document record, such as the document location.
To achieve this, we are using the D365 Web API.
However, the response we are getting from the API is empty, and no data is being retrieved from the SharePoint document table — not even for a single record.We have confirmed that the SharePoint integration is active, and the API request is correctly configured. Despite this, the SharePoint document entity does not return any fields or values in the response.



I have the same question (0)
  • Suggested answer
    DAnny3211 Profile Picture
    11,421 Super User 2026 Season 1 on at

    Hi,

    This issue typically occurs when the SharePoint document integration is active, but the SharePoint document entity (document locations) is not properly exposed or accessible via the Web API.

    Here are a few things to check and try:

    1. Verify Entity Permissions

    Ensure that the SharePointDocumentLocation entity (or related custom entity) has the correct security roles and field-level security enabled for the user or application calling the API.

    2. Use the Correct Entity Name

    Sometimes the logical name used in the API call is incorrect or outdated. Try querying:

    /api/data/v9.2/sharepointdocumentlocations?$filter=regardingobjectid/accountid eq <GUID>

    Or use $expand=regardingobjectid to retrieve related record info.

    3. Check for Null or Empty Fields

    If the document location exists but fields are empty, it could be due to:

    • Missing metadata mapping
    • Incomplete document association
    • Custom button not passing the correct record context

    4. Use Browser Dev Tools to Inspect the Grid

    When clicking the custom button, use browser dev tools to inspect the selected row’s data context. Ensure the correct regardingobjectid or documentlocationid is being passed to the API.

    5. Test with Postman or API Tester

    Try calling the same API endpoint using Postman with the same credentials. If the response is still empty, the issue is likely with the data or permissions, not the button logic.

    Let me know if you can share the exact API call you're using or the structure of the response — happy to help debug further.

    Best regards,
    Daniele 

  • CU12050506-0 Profile Picture
    12 on at

    Hi @DAnny3211,

    Thank you for your detailed response and helpful suggestions.

    However, I just wanted to clarify that my requirement is to retrieve data from the SharePointDocument table, not the SharePointDocumentLocation table. I understand that both are related, but my focus is specifically on accessing the actual SharePoint documents linked to records.

    If there are any specific considerations or best practices when working with the SharePointDocument entity via the Web API, I’d really appreciate your input.

    Thanks again for your support!

     

  • VJ7 Profile Picture
    2 on at
     
    I'm looking for an option to retrieve the sharepointdocument record using GUID. I'm wondering if you find a way to achieve this.
     
    Thanks,
    VJ
  • Suggested answer
    Niki Patel Profile Picture
    114 on at
    Hi,
    If you're querying the sharepointdocument entity via Web API and getting either a 404 or an empty value: [] response - here's why and how to fix it.
     
    Root Cause
    The sharepointdocument entity is a virtual entity. It has no physical rows in the database. Records are dynamically resolved at runtime in the context of a parent record (Account, Contact, Opportunity, etc.). This means:
    - Direct GUID lookup -> 404 (the record doesn't exist in DB)
    - Global query with no filter -> empty result
     
    Fix 1 - Read directly from the selected grid row (Recommended)
    If your button is on the SharePoint document subgrid, the data is already loaded. No extra API call needed:

    function onButtonClick(selectedControl) {
        const selectedRows = selectedControl.getGrid().getSelectedRows();
        if (selectedRows.getLength() === 0) {
            Xrm.Navigation.openAlertDialog({ text: "Please select a document." });
            return;
        }
        selectedRows.forEach(function(row) {
            const entity = row.getData().getEntity();
            const locationName = entity.attributes.get("locationname")?.getValue();
            const absoluteUrl  = entity.attributes.get("absoluteurl")?.getValue();
            const title = entity.attributes.get("title")?.getValue();
            const fileType = entity.attributes.get("filetype")?.getValue();
            console.log("Location:", locationName);
            console.log("URL:", absoluteUrl);
        });
    }
     
    Fix 2 - Web API query with parent record filter
    If you must use the Web API, always filter by the parent record's ID:

    const parentId = Xrm.Page.data.entity.getId().replace(/[{}]/g, "");
    const entityLogicalName = "account"; // change as per your parent entity
    const result = await Xrm.WebApi.retrieveMultipleRecords(
        "sharepointdocument",
        `?$filter=regardingobjectid_${entityLogicalName} eq '${parentId}'` +
        `&$select=locationname,absoluteurl,title,filetype,relativelocation`
    );
    console.log(result.entities);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 135

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 82 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 57

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans