This small post documents the steps and expressions for updating the row in Dataverse table after a file has been uploaded to SharePoint.
A common requirement is to update the record row in Dataverse
table after a file has been uploaded to SharePoint. This small post documents the steps and expressions for it. For demonstration, I'm using “Account
” table and have created “URL
” a custom column in it. After the file uploads, I will update the row and safe URL in this field.
Summary
This post does not cover the steps required to configure SharePoint for document storage with Model-Driven App. Follow this link for integration details). Cloud flow triggers when a file is uploaded from Model Driven App and created in the SharePoint document library.
- Create a cloud flow and add “
When a file is created (properties only)
” trigger. Configure the following properties:
Site Address
Library Name
- To upload
Dataverse
row, we need GUID
. Unfortunately, it is not available as plain text, though we can drive it from trigger’s Folder path property.
Its value will be similar to account/test_67B9406FCBB7EB118236000D3A6A4A8A/.
We need to extract GUID from it. The expression which I have used uses three functions and here is the complete expression:
replace(last(split(triggerOutputs()?[‘body/{Path}’],’_’)),’/’,")
Need an explanation?
split(triggerOutputs()?[‘body/{Path}’],’_’)
will divide account/test_67B9406FCBB7EB118236000D3A6A4A8A/ into two from ‘_
’. Wrapping it under last function will return 67B9406FCBB7EB118236000D3A6A4A8A/ only. I have used replace function to remove last ‘/’.
- In Step 2, we got the GUID but it is not in a format that we can use to fetch or update row. Instead of:
67B9406FCBB7EB118236000D3A6A4A8A
We need it in 67B9406F-CBB7-EB11-8236-000D3A6A4A8A
format.
Here is the expression that will do this:
concat(substring(variables(‘StringGUID’),0,8),’-‘,
substring(variables(‘StringGUID’),8,4),
’-‘,substring(variables(‘StringGUID’),12,4),’-‘,
substring(variables(‘StringGUID’),16,4),
’-‘,substring(variables(‘StringGUID’),20,12),")
In this post, I have explained this expression.
- The last steps is to use
FormatedGUID
and update record. For demo purposes, I have created a custom field “URL
” and populated the document URL in it.
Let's test the Flow after turning it on.