You are currently viewing Setting up Custom SharePoint Connections to Dataverse Record

Setting up Custom SharePoint Connections to Dataverse Record

2/20/2023


The Why

When integrating Dataverse and SharePoint, it's important to segregate documents from the default site. This helps ensure that only authorized users have access to the document libraries. By keeping the libraries separate, you can maintain better control over the documents and their distribution.

The How

Prior to using this guide the Default site needs to be configured

Setting up Default SharePoint Connections to Dataverse Record

Setting up the SharePoint Document Library

Because we are not using the default site, we will need to create the SharePoint Document library. From the desired SharePoint Site navigate to Site Content and create a new document library

Give the library a distinct name, we will be using this in a later step.

Setting up the SharePoint Connection

  1. Select SharePoint Sites
  2. Select New
  3. Give the site a unique name and type in the URL to the SP site
  4. Save the Site and the Document Location.
  5. Select SharePoint Document Locations
  6. Select New
  7. Give the location a distinct name
  8. Under Parent Site, use the SharePoint site created above, for the relative URL enter in the SharePoint Document Location that was created earlier.

Creating the folder

Since we are not using the default site, Dataverse will not automatically create a SharePoint folder when a new record is added. To solve this issue, we need to create a Power Automate Flow to generate the folder for us.

The Trigger is when a row is added to the Table

A Compose Action is used to create the folder name

toUpper(triggerOutputs()?['body/eddev_customerrequestsid'])

A Create Folder Action in SharePoint Is then executed. The site will be the the one from above, the library will be the library configured above. The folder path will be the output of the compose.

The Next step will be to use Get the GUID of the Dataverse linkage created earlier. The relativeurl and name can be gathered from step 8 of setting up the SharePoint Connector

relativeurl eq 'PurchaseRequest' and name eq 'Purchase Request'

Then adding a record into the Document Location Dataverse Table

The Parent Site will be the output of the list rows from above. Use the first expression to avoid a loop.

first(outputs('List_rows')?['body/value'])?['sharepointdocumentlocationid']

The Regariding Customer Requests will be the ID of the trigger. To properly set this, you will need to get the entity set name. Use the code below to get the name. Replace the ORGID with your ORGID.

https://ORGID.crm9.dynamics.com/api/data/v9.1/EntityDefinitions(LogicalName='TABLELOGICALNAME')?%24select=EntitySetName

Leave a Reply