Getting Share Point Document URL in Dynamics 365 CE

Introduction
Sometime we required to get full path of the image which we have uploaded to Share Point document for specific entity. In this article I am going to demonstrate how Microsoft Flow can be used to implement this requirement. Feel free to comment if there is another easy of doing this.

This article is assuming you have basic understanding of Dynamics 365 CE Share Point integration and Flow as well as Share Point integration is already configured.Keep in mind this is for the demo purpose but you can change it accordingly to your requirement.

Details

Let’s add a string field in the Contact entity where we are going to store URL, our field look like below
Imageurl

Now Navigate to Flow and using Following steps:

> Click on New and select automatic flow having following trigger

Imageurl1

> Let’s name our flow as “Set Image URL For Contact” and set action properties like below:
Imageurl3

> Now let’s add some variable which we require for formatting URLs, Click on + New Step and search for variable and select Initialize Variable, In this variable we are going to set our Share Point Site URL.
Imageurl4

> Add another integer type variable, where we are going to store last index of “/” in URL, it should look like following:
Imageurl5

In above express I am using following formula

lastIndexOf(triggerBody()?[‘{Path}’],’/’)

> Add another variable and call it Folder path, we will be setting this variable at later stage
Imageurl6

> We need other variable to store image extension like following to validate specific file extension you can use based on your requirement.
Imageurl7

We are using following formula in above variable

last(split(triggerBody()?[‘{FilenameWithExtension}’], ‘.’))

> Add a condition and add condition to check folder and file extension like following
Imageurl8

> Now under yes, blow first we are going to set folder path, this step may vary based on your entity name ,

Imageurl9

I am using following formula to set variable
substring(triggerBody()?[‘{Path}’],8,sub(variables(‘lastindex’),8))

Above 8 is count of entity +1 so for example cotnact/ will be 8

> Next we need to query document location record based on the folder path, we can use Dataflex (Common Data Service current) connector. Select List records and set it’s property like following

Imageurl10

In above we are going to query Document Locations record based on the Folder Path variable

> Finally add a Update action from Dataflex (Common Data Service current) connector and set it’s properties like following

Imageurl11

Apply to each loop will be automatically applied when we will set field returned from Document Location record step. Finally our flow should look like below
Imageurl12

Finally try to upload image to your entity you should see image URL populated after some time

filename

Summary
So if you are need file name with extension or need path of the file you can use above Flow to store file name in CRM.

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

Leave a Reply

Your email address will not be published. Required fields are marked *