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
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
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
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
> 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
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.
> Add another variable to hold contact id and use formula to format and remove “-” from GUID like following.
> 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
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
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.
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 !!
I have added expression. thanks!
Great ideas I have applied in my crm and contact manager app. Thanks a lot for sharing been very helpful to me.
Sorry for late response but I hope you already figured it out, if not you can use primary attribute to get GUID and format it using expression.