Creating Document Location Record using Flow

Introduction
When we create entity record manually and upload document to that entity under Document grid, Dynamics 365 CE creates Document Location record and setup folder in Share Point for that entity, but if we are creating entity record using other option and want to attached document to entity, first we need to create Document Location record and Share Point folder for that entity. In this article we are going to discuss about creating Document Location and Share Point folder using Flow.

Details
Let’s first note what are the prerequisite to create document location.
Prerequisite
First you need to make sure that Share Point integration is setup in your organization. For our demo we are not using any specific entity folder like below

qU5tgLVBr9

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

1. Create a dummy contact record
2. Navigate to Related -> Documents and upload a test
3. Select file and click on Open Location to make sure it’s opening correct Share Point location

chrome_wgPvCS4xgJ

4. Navigate to Settings -> Document Management -> Share Point Document Locations and open document location record created for your test contact.
5. Click on Parent Site or Location lookup to open record and note the GUID of the record from 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 details what we require, so let’s start creating our flow.
> Navigate to Accounts and select Create Flow under flow drop down, as we want to Create contact record from Account
Createflow

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

> Click on + sign to add new step
> Search for Common Data Service (current environment) connector and select Create New Record action from it
> Fill details like following
chrome_Ethiq5UZhP

In above step we are creating contact using account information using dynamics contents.
> Click on + and add a variable to hold Parent Share Point Site location like below and use the GUID we captured in step 5 above.
chrome_FfxjrJkQjC

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

 

We have used following expression to format GUID
toUpper(replace(outputs(‘CreateContact’)?[‘body/contactid’],’-‘,”))

> Again click on + sign and look for same common data service connector and select Create New Record action
> We need to create Document Location Record and need to fill properties using dynamics contents like following

chrome_NIEwCWf9R2

Above action will create document location record in CRM but now we also need to create this folder in Share Point.
> Again Click on + sign and select Create New Folder action under Share Point and fill details like below
chrome_hTnVG1bQb5

Above step will create folder under contact library for our new contact record using it’s GUID.

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

Annotation 2020-07-23 115215

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

> We need to setup lookup using following way
/accounts/@{triggerBody()?[‘entity’]?[‘accountid’]}
> While using GUID for Share Point we need to remove “-” and change it to upper case

Hope it will help someone!
Keep learning, Keep sharing !!

One thought on “Creating Document Location Record using Flow

Leave a Reply