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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add Attachment to Shar...
Power Apps
Suggested Answer

Add Attachment to SharePoint Document Management (Dataverse) direct from Power Automate

(1) ShareShare
ReportReport
Posted on by 439
Hello everyone,
 
I'm sure this must be a common use case but I can't spot a solution.
 
I have a Dataverse Table with SharePoint Document Management enabled ('Make this table an option when.... Setting up SharePoint Document Management' is checked (resource: Matt Devaney's excellent blog article). Files that I want to store in the related SharePoint Document Library will be arriving from an API, via Power Automate.
 
The problem is, I can't see how to save the file from Power Automate directly in to the SharePoint document library whilst linking the file to the relevant record in the Dataverse Table.
 
For example:
1. I can't save the file direct to SharePoint, otherwise, how is it linked to the relevant record in Dataverse? (Edit: The record in Dataverse will be created at the same time that I need to add the File, so, there will not be a document folder in SharePoint that relates to the Dataverse record yet. In other words, I can't perform a look up to the record's document folder in SharePoint yet, as it doesn't exist. Looking at the format of the names of those folders, they are not simply the record's GUID, so I don't think I can make a new folder in the SharePoint document library, as it will not be possible to predict what auto-numbering is given to the folder by Dataverse/SharePoint).
 
2. I can't save the file to a 'File' column in the Dataverse table, otherwise it will be stored in Dataverse and not the SharePoint document library.
 
What is the correct methodology?
 
Thank you!
Categories:
I have the same question (0)
  • Suggested answer
    MParikh Profile Picture
    322 Super User 2025 Season 2 on at

    The correct approach:

    1. Create the Dataverse record using the Dataverse connector in Power Automate. Store the returned record ID (GUID).
    2. Trigger creation of the SharePoint folder linked to that Dataverse record. You can do this using Power Automate’s built-in action to "Create a new Document Location":
      • Set the site and relative URL.
      • Set the “Regarding” field to the GUID of your Dataverse record.
      • This step ensures that the correct folder is created in SharePoint and properly linked to the Dataverse record.
    3. Upload the file to that folder in SharePoint using the "Create file" action in Power Automate:
      • Use the site and folder path that was created in the previous step.
      • Upload the file content from your API.
    At this point, the file is in the right SharePoint folder and automatically associated with the Dataverse record.
     
    Another Option:
     
    Why not just use a Dataverse File column?
    Because then the file is stored in Dataverse itself, not in SharePoint.
     
  • pp365 Profile Picture
    439 on at
     
    Thank you for your reply. I've tried to follow these instructions but do not see an available action in the SharePoint Connector named "Create a new Document Location";
     
     
    I have also tried a speculative search in Power Automate for 'Create a new Document Location' and I don't see an action for any connector available to me that matches this phrase.
     
    Please can you advise where this action is located, and/or what the correct name of the action is?
     
    In answer to your question about storing the file in Dataverse, this is not feasible/is not the use case here - the files will be large and in quantity, hence offloading them to SharePoint Document Management.
     
    Thank you very much again for your help.
  • pp365 Profile Picture
    439 on at
    Hello @MParikh , everyone , I am still looking for help on this topic.
     
    I have found a table called "Document Location" in Dataverse (Tables > All Tables); partly sanitised screenshot is below. I can't see how it's generating the records for this table. For example, the "Relative URL" seems to have some sort of auto generated ID before the GUID, "1019", "1020" - why has it started this list at 1019, how can this be predicted for future document additions, etc.?
     
    The other question is why the first row is different to the other two, I am assuming this is some internal config of the linked SharePoint site  and not a document.
     
    I am hopeful someone can give some assistance here. Thank you very much!
     
     
     
  • Suggested answer
    MParikh Profile Picture
    322 Super User 2025 Season 2 on at

    What is the "Document Location" Table?

    The Document Location table (sharepointdocumentlocation) in Dataverse is used to map records in Dataverse (like an Account, Case, or Custom Entity) to folders in SharePoint.
    Each row:
    • Represents a location in SharePoint
    • Is used to tell the app where to store or find documents for a given record
    • Is automatically created by the platform when you enable SharePoint integration and access the Documents tab on a record form
    Why are the "Relative URL" values prefixed with numbers like 1019, 1020?
    This is standard behavior:
    When you open the "Documents" tab on a record for the first time, the system:
    1. Automatically creates a folder in SharePoint under the entity’s root folder.
    2. Creates a corresponding Document Location record in Dataverse.
    3. The folder name in SharePoint is based on:
      • Record’s primary field (e.g., Account Name)
      • And a unique numeric suffix like 1019, 1020, etc., to avoid duplicates.
    These numbers (like 1019) are:
    • Auto-incremented IDs for uniqueness
    • Not controlled by Dataverse
    • Generated by SharePoint, not Dataverse
    • Cannot be reliably predicted

    Why is the first row different from the others?

    You’re likely seeing something like this:

     
    Name Relative URL Regarding
    Root Location sites/yourSiteName (blank or site)
    Some Account - 1019 sites/yourSiteName/Accounts/1019-GUID Account record
    Another Account - 1020 sites/yourSiteName/Accounts/1020-GUID Account record
     
    • First row: This is the root document location for the site. It maps the base site URL and is used internally as a parent folder location.

    • Other rows: These are child document locations created when SharePoint integration is triggered for a specific record.
  • pp365 Profile Picture
    439 on at
     
    Thank you for your detailed reply, however...
     
    [...]
    "Is automatically created by the platform when you enable SharePoint integration and access the Documents tab on a record form"
    "When you open the "Documents" tab on a record for the first time, the system [...]"
    "Cannot be reliably predicted"
     
    In that case how am I supposed to model this in a Power Automate flow? 
     
    Going back to your original post, and my follow up question five days ago below, any pointers on if you can clarify the step I cannot find within the UI that you have mentioned "Create a new Document Location"?
     
    Someone out there must have used this functionality, surely. I am again appealing for any help on this, please. 
     
    Thank you.
  • pp365 Profile Picture
    439 on at
    Anyone available to assist please? Attempting to raise the profile of this again by responding. Thank you.
  • pp365 Profile Picture
    439 on at
    Another appeal for assistance, can anyone advise please, thank you.
  • Suggested answer
    MParikh Profile Picture
    322 Super User 2025 Season 2 on at
    Hey pp365,
     
    Try following below steps. Good Luck!

    Create a Document Location from Power Automate

    1. Use a Dataverse "Add a new row" step
      • Table: sharepointdocumentlocation
      • Key fields:
        • Name: Give it something identifiable like "Documents for [Account Name]"
        • RelativeURL: Your intended SharePoint path (e.g., "Accounts/1019-GUID")
        • Regarding (regardingobjectid_account@odata.bind): Reference the record (e.g., accounts(<account GUID>))
        • Parent Site or Location (parentsiteorlocation@odata.bind): Reference the root location (you can retrieve this once and store the GUID in an environment variable)
    2. Create the SharePoint folder manually (if it doesn’t exist yet)
      • Use the SharePoint "Create folder" action
      • Make sure the folder path matches what you’ll store in the RelativeURL above
    🔁 Optional: Check if the Document Location already exists
    Before creating a new one, use a Dataverse List Rows action to query the sharepointdocumentlocation table filtered by Regarding and RelativeURL.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard