Creating Document Location Record Using Flow

Introduction

When we create an entity record manually and upload documents to that entity under the Document grid, Dynamics 365 CE creates a Document Location record and sets up a folder in SharePoint for that entity. But if we are creating an entity record using another option and want to attach the document to an entity, first we need to create a Document Location record and SharePoint folder for that entity. In this article, we are going to discuss creating a Document Location and SharePoint folder using Flow.

Details

Let’s first note what are the prerequisites to create a document location.

Prerequisite

First, you need to make sure that SharePoint integration is set up in your organization. For our demo, we are not using any specific entity folder like below,

 SharePoint integration

Now let’s first manually create a contact record upload document and note down parent site details, we can follow the below steps,

  1. Create a dummy contact record
  2. Navigate to Related, Documents and upload a test
  3. Select the file and click on Open Location to make sure it’s opening the correct SharePoint location
    Open Location
  4. Navigate to Settings -> Document Management -> SharePoint Document Locations and open the document location record created for your test contact.
  5. Click on Parent Site or Location lookup to open the record and note the GUID of the record from the address bar (note: We can also write a step in flow to query this but for the demo purpose we are using GUID here).

Now we have the details of what we require, so let’s start creating our flow.

Navigate to Accounts and select Create Flow under the flow drop-down, as we want to Create a contact record from the Account.

 Create Flow

This will take you to Flow, if you are using Flow for the first time it may ask you to set it first. You will get a screen like the following, click on Continue

Common data

Click on the + sign to add a new step.

Search for the Common Data Service (current environment) connector and select the Create New Record action from it.

Fill in details like the following.

 Create New Record

In the above step, we are creating contact using account information using dynamics contents.

Click on + and add a variable to hold the Parent Share Point Site location like below and use the GUID we captured in step 5 above.

 Parent Share Point Site

> Add another variable to hold contact id and use the formula to format and remove “-” from GUID like the following.

GUID

Again click on the + sign look for the same common data service connector and select the Create New Record action.

We need to create a Document Location Record and fill properties using dynamic content like the following.

Document Location Record

The above action will create a document location record in CRM but now we also need to create this folder in Share Point.

Again Click on the + sign select Create New Folder action under Share Point and fill in the details below.

 New Folder action

The above step will create a folder under the contact library for our new contact record using its GUID.

Now save your flow navigate to CRM under accounts and run flow to test, it should create a contact record and should set the document location record for the new contact.

CRM

Summary

Using the above steps we can create a document location record using flow. We need to keep the following things in mind while creating document location records using flow and common data service current connector

We need to set lookup using the following way

/accounts/@{triggerBody()?[‘entity’]?[‘accounted]}

While using GUID for Share Point we need to remove “-” and change it to upper case

I hope this will help someone!

Keep learning, Keep sharing!


Similar Articles
HIMBAP
We are expert in Microsoft Power Platform.