- Introduction
- Shoutout to Keegan
- Solution
Introduction
I want to start by saying that my recent work with Power Pages has been a significant learning experience. While I had some idea of what I was getting into, I had to quickly upskill. Here’s the key takeaway: don’t fear what you don’t know. Fear of the unknown often holds us back, especially in the tech world, where there are always countless uncertainties. We use tools to build solutions and inevitably face gaps or unknowns along the way. Instead of shying away, embrace those unknowns, expect them, and take action. Soapbox moment over.
Shoutout to Keegan
I have to acknowledge my colleague, Keegan, for this. We worked on a Power Pages project with SharePoint integration and want to ensure that only external users can view external-facing documents. Internally, a reviewer will upload documents to the external user’s record. While the internal reviewer will have access to all documents in the library, the external user will be restricted to documents stored in an external-facing SharePoint folder.
We experimented with several approaches to implement the segregation, but nothing seemed to work. Initially, we considered adding a metadata field to the document library to flag files or folders as external, then using JavaScript in the portal to filter out the results. However, I was concerned that if the JavaScript failed or loaded slowly, it could inadvertently expose sensitive files to users who shouldn’t have access. That potential risk made me uncomfortable with relying on this approach.
We noticed there had to be an internal process Microsoft uses to decide which folder gets surfaced in the subgrid. It was Keegan who suggested that maybe the ‘Created On’ field in the Document Locations Dataverse table was being used to determine which folder gets displayed. And sure enough, that was the case. So, big shoutout to Keegan for that insight. He even suggested I write an article about it, but I have no problem giving credit where it’s due—he’s a great guy.
Solution
I won’t be covering the process of setting up SharePoint integration with Power Pages in this article, but I will go over the basics of our table permissions. Anything beyond that is outside the scope of this discussion. If you’re unfamiliar with the SharePoint integration setup, please visit Manage SharePoint documents. Once you’re comfortable with that, return to this article and pick up the instructions from there.
Step 1: Configuring the Basic Form
For our solution, we didn’t need to use the entire Dataverse form; we just needed a simple space to upload files. You can choose to use the full form or modify it to fit your needs. We’ll be uploading our forms to a table we named “Site.” A quick note: avoid naming a table in your Dataverse environment “Site.” Power Pages uses a table called “Site” that holds the site record for the Power Pages website, so using the same name could cause conflicts within the environment.
Whatever permissions you set on the form; I recommend changing the parent permission to “Global” for the purposes of this discussion. You can adjust the permissions later based on your specific needs, but for now, this will help show functionality. Once you change the parent permission’s access type, we should be all set. Still, please note—until we complete the Power Automate flow, I suggest against uploading anything into the subgrid. You’d likely have to delete it later anyway.
Aside: Spoofing the System
One thing we noticed when manually walking through this process is that in the Document Location table in Dataverse, the first Document Location record “wins” and becomes the default. This is why we need to “spoof” the system a bit. When the first file or folder is added, it automatically creates the parent document location in Dataverse, which we don’t want in this case. Instead, we want to create the external document location first. Once that’s done, we create the parent document location. After the parent is created, we’ll associate it with the external document location. This ensures that the external location takes priority in the subgrid, making it visible only to external users on the Power Pages website, while files or folders outside of the external folder structure and including the external folder will still be visible to internal users via the model-driven app.
Step 2: Building the Flow
Building out the flow is fairly straightforward. We want to automatically create the folder structure every time a new site is created, ensuring that when documents are uploaded from Power Pages, they are always directed into the external-facing folder. To implement this design effectively, we’ll use an automated trigger.
1. Trigger: When a row is added, modified, or deleted
This trigger will monitor the creation of new sites and automatically build the necessary folder structure, making sure the external folder is ready for document uploads.
SharePoint Actions
To achieve the necessary design for our folder structure, we will be using two SharePoint actions. These actions will create both the parent folder and the external folder nested inside the parent folder. Both actions will utilize the “Create new folder” action.
2. Create new folder (Create Parent)
- Site Address:
This should be the location of your document integration. If you’re unsure of the SharePoint site location for the integration, you can review the document management settings in Advanced Settings to find it. - List or Library:
Library where your documents are stored, check the site contents of the SharePoint site to verify the document library where you want your documents to be stored. - Folder Path:
The folder path will be a concatenation of the Site Name and the Site GUID, separated by an underscore (_). This ensures a unique folder structure for each site created.
replace(concat(triggerOutputs()?['body/dul_name'],'_',toUpper(triggerOutputs()?['body/dul_siteid'])),'-','')
This setup will create the parent folder, setting the foundation for further customization with the external folder inside.
2. Create new folder (Create External Documents)
- Site Address:
Use the same site address as the Create Parent action. - List or Library:
Select the same document library as the Create Parent action. - Folder Path:
Using the dynamic content from the previous action, select the Title of the folder created in the parent action, then add a forward slash (/) and specify the name of your external documents folder (e.g.,0External_Documents).
This will nest the external folder inside the parent folder, ensuring that all external-facing documents are uploaded into the appropriate folder structure.
Dataverse Actions
Once the folder structure is set up in SharePoint, the next step is to establish the corresponding Document Location in Dataverse. Before proceeding with any Dataverse actions, navigate to make.powerapps.com and open the Document Locations table. Find and extract the GUID for the default site’s Document Location record, which should be titled “Documents on Default Site.” This GUID is crucial for the Dataverse actions you’re about to implement, so make sure the record is available and correctly identified before continuing.
1. Add a New Row (Create External Document Location Record):
- Table Name:
Document Locations - Name:
External Documents - Parent Site or Location (Document Locations):
sharepointdocumentlocations({GUID of Default Site record}) - Regarding (Sites):
dul_sites({GUID of the site in the trigger}) - Relative URL
0External_Documents
(Note: “Sites” is the table name being used for SharePoint integration in this example. Your table name may differ.)
It is essential to create the external document location record before proceeding with any further steps.
2. Add a New Row (Create Parent Document Location Record):
- Table Name:
Document Locations - Name:
Trigger Name - Parent Site or Location (Document Locations):
sharepointdocumentlocations({GUID of Default Site record}) - Regarding (Sites):
dul_sites({GUID of the site in the trigger}) - Relative URL
replace(concat({Name of Trigger},’_’,toUpper({GUID of Trigger})),’-‘,”)
(Note: “Sites” is the table name being used for SharePoint integration in this example. Your table name may differ.)
3. Update a Row (Change Parent Site on External Folder)
- Table Name: Document Locations
- Row ID:
{GUID of External Folder Document Location} - Parent Site or Location (Document Locations):
sharepointdocumentlocations({GUID of Parent folder})
It’s crucial to update the parent site or location to align with the folder structure in SharePoint. This process leverages relative URLs, so it’s important that the relative URLs follow a consistent hierarchy. For example:
- Default Site Relative URL:
dul_site - Parent Relative URL:
LinkedInTestSite - External Folder Relative URL:
0External_Folder
By correctly linking these records, the fully constructed URL will follow the pattern: dul_site/LinkedInTestSite/0External_Folder. This ensures the folder structure in Dataverse matches the structure in SharePoint, maintaining consistency and proper document organization.




In practice
Steps to Set Up the Internal Subgrid:
1. Open the main form for your table.
2. Add a subgrid to the form.
3. In the subgrid properties, select Related Records.
4. Choose Documents (Regarding) from the list.
5. Select All SharePoint Documents.
6. Save the changes.
7. Publish the form to apply the updates.
Test out internal subgrid
- Navigate to the table with the integration and select a record.
- Click Edit to open the form.
- In the subgrid, choose the Document Location dropdown and select All Locations. This will display all files in the folder structure.
In my case, the internal subgrid shows 5 records, including those uploaded from Power Pages or residing in the External Documents folder, but on the Power Pages side, only 3 files are visible.
- This is because documents on the Power Pages side are written to the External Folder, so only documents in that folder will be visible to external users.
Important: If you upload a file to any location other than the External Folder, it will not be accessible to external users.
If you select the External Documents tab in the internal subgrid and upload a file, it will be added directly to the External Folder, making it visible to external users.

