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
Now Navigate to Flow and using Following steps:
> Click on New and select automatic flow having following trigger
> Let’s name our flow as “Set Image URL For Contact” and set action properties like below:
> 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.
> Add another integer type variable, where we are going to store last index of “/” in URL, it should look like following:
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
> We need other variable to store image extension like following to validate specific file extension you can use based on your requirement.
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
> Now under yes, blow first we are going to set folder path, this step may vary based on your entity name ,
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
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
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
Finally try to upload image to your entity you should see image URL populated after some time
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 !!