Row Update After SharePoint File Upload

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 file uploads, I will update the row and safe URL in this field.

Summary

This post do 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.

  1. Create a cloud flow and add “When a file is created (properties only)” trigger. Configure the following properties:
    • Site Address
    • Library Name

2. 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. Expression which I have used uses three functions and here is complete expression:

replace(last(split(triggerOutputs()?[‘body/{Path}’],’_’)),’/’,”)

Need 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 ‘/’.

3. In step 2, we have got the GUID but it is not in format that we can used to fetch or update row. Instead of

67B9406FCBB7EB118236000D3A6A4A8A

we need it in 67B9406F-CBB7-EB11-8236-000D3A6A4A8A format.

Here is 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 explain this expression.

4. Last steps is to use FormatedGUID and update record. For demo I have created a custom field “URL” and populating document URL in it.

Lets test the Flow after turning it on.

Let’s Connect

 twIcon lnIcon fbicon

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s