Manage SharePoint documents
Common Data Service supports integration with SharePoint Online that enables you to use the document management capabilities of SharePoint from within Common Data Service. PowerApps portals now supports uploading and displaying documents to and from SharePoint directly on an entity form or web form in a portal. This allows portal users to view, download, add, and delete documents from a portal. Portal users can also create subfolders to organize their documents.
- Document management works only with SharePoint Online.
- Document management is supported with server-based integration.
To work with the document management capabilities of SharePoint from within Common Data Service, you must:
Step 1: Enable document management functionality in model-driven apps in Dynamics 365
You must enable the document management functionality in model-driven apps in Dynamics 365 by using server-based SharePoint integration. Server-based SharePoint integration allows model-driven apps in Dynamics 365 and SharePoint Online to perform a server-to-server connection. The default SharePoint site record is used by the portal. For information on how to enable document management functionality in model-driven apps in Dynamics 365, see Set up model-driven apps in Dynamics 365 to use SharePoint Online.
Step 2: Set up SharePoint integration from PowerApps Portals admin center
To use the document management capabilities of SharePoint, you must enable SharePoint integration from the PowerApps Portals admin center.
You must be a global administrator to perform this action.
Go to Set up SharePoint integration > Enable SharePoint integration.
Select Enable in the confirmation window. This will enable the portal to communicate with SharePoint. While the SharePoint integration is being enabled, the portal restarts and will be unavailable for a few minutes. A message appears when SharePoint integration is enabled.
When SharePoint integration is enabled, the following action becomes available:
Disable SharePoint integration: Allows you to disable the SharePoint integration with your portal. While the SharePoint integration is being disabled, the portal restarts and will be unavailable for a few minutes. A message appears when SharePoint integration is disabled.
Enabling or disabling the SharePoint integration will update the Azure Active Directory (Azure AD) application for the portal and add or remove the required SharePoint permissions, respectively. You will also be redirected to provide your consent for the changes to be made in the Azure AD application.
If you do not provide your consent:
Enabling or disabling the SharePoint integration will not be complete and an error message will display.
Your out-of-the-box Azure AD login on the portal will not work.
Step 3: Enable document management for entities
You must enable document management for entities to store documents related to entity records in SharePoint. For information on how to enable document management for entities, see Enable SharePoint document management for specific entities.
Step 4: Configure the appropriate form to display documents
Identify the form where you want to use document management capabilities. You must edit the form by using model-driven app form editor and add a subgrid to it. The subgrid adds a section to the form, which allows you to work with documents from within a portal. You must set the following properties in the subgrid for this feature to work:
Under Data Source, select Document Locations from the Entity list.
Under Data Source, select Active Document Locations from the Default View list.
You can specify name and label as per your requirement. Save and publish the form once the subgrid is added and configured.
Document management must be enabled for the entity for which you edit the form. More information: Enable document management for entities
PowerApps portals configuration
Apart from the standard configuration required for entity form or web form, you must set the following properties to enable document management:
Entity Name and Form Name: Enter the entity and form names customized in the previous step, respectively.
Select the Enable Entity Permission check box on the form to allow a user to read the documents.
Set the Mode to Edit to allow document uploads.
Document uploading requires the parent entity record to exist. If you set the Mode to Insert, the document upload will not work because the parent entity record is not created until the form is submitted.
Step 5: Create appropriate entity permission and assign it to the appropriate web role
Two entity permission records are required to establish the necessary access to view and upload documents.
- Permissions on the entity of the entity or web form:
- Create an Entity Permission record specifying the Entity Name as the entity of the entity form or web form configured previously.
- Select a Scope and scope relationship that is appropriate to the desired behavior of the form.
- Enable Read and Append To privileges to allow read access to documents and optionally enable Write privilege to allow document uploads. Ignore the Child Entity Permissions section for now since it will be populated by the next step.
- Permissions on the Document Location with Parent scope referring to the previous permission record:
- Create an Entity Permission record specifying the Entity Name as Document Location entity with Scope set to Parent.
- Select the Parent Entity Permission to the entity permission record created in previous step.
- The minimum privileges to allow read access to documents are Read, Create, and Append.
- Include Write privileges for document upload access.
- Include Delete to allow deletion of a document.
A corresponding child entity permission on the Document Location entity needs to be created for each instance of the parent entity permission record that exists on the entity of the entity or web form where documents need to be shown.
Configure file upload size
By default, the file size is set to 10 MB. However, you can configure the file size to a maximum of 50 MB by using the site setting
Sample configuration to enable document management on the Case entity form
The below example demonstrates configuration using the Case entity which needs the Dynamics 365 Customer Service application as a pre-requisite. Although this sample uses the Case entity, it is just an illustration of the steps mentioned above and can be followed with any other custom entity or any Common Data Service entity that supports managing documents in SharePoint.
Follow the instructions in Step 1 to ensure that server-based configuration is complete for model-driven apps in Dynamics 365 and SharePoint integration.
Follow the instructions in Step 2 to ensure that the portal has permissions to integrate with SharePoint.
Follow the instructions in Step 3 to ensure Document Management is enabled for the Case entity.
Follow the instructions in Step 4 with the following configurations:
Model-driven apps in Dynamics 365 customization
a. Go to Settings > Customization > Customize the System.
b. In the Default Solution, go to the Case entity > Forms.
c. Open the Web – Edit Case in form editor.
d. Select the Created On field on the form, and on the Insert tab, select Sub-Grid.
e. In the Set Properties dialog box, set the following properties, and select OK:
Name (This can be any name): CaseDocuments
Label (This can be any label name): Case Documents
Entity: Document Locations
Default View: Active Document Locations
f. In the form editor, select Save and then select Publish.
PowerApps portals configuration
a. Go to Portals > Entity Forms.
b. Find and open Customer Service - Edit Case entity form.
c. Review and ensure the following properties are set:
Entity Name: Case (incident)
Form Name: Web – Edit Case
Entity Permission: Enabled
d. If you’ve made any changes to the form, select Save.
Follow Step 5 to make sure entity permissions are granted to the users.
Go to the Web Role record that is associated to the user. For this sample, we’ll assume that the user has an Administrator web role.
Ensure that an Entity Permission record exists by the name of Customer Service - Cases where contact is customer.
Ensure that your web role has this entity permission added. If your user is already an Administrator, then the above entity permission need not be explicitly assigned.
Create a new entity permission, enter the following details, and select Save:
Name (This can be any name): Customer Service - Related Documents
Entity Name: Document Location
Parent Entity Permission: Customer Service - Cases where contact is customer
Parent Relationship: incident_SharePointDocumentLocations
Privileges: Read, Create, Append, Write, Delete
Sign in to portal to ensure document management is enabled for the Case entity.
a. Go to the Support page.
b. Click on an existing Case record from the list. Go to the Case Documents section on the page and see the document list added.