Click here to Skip to main content
15,121,641 members
Articles / Productivity Apps and Services / Sharepoint
Technical Blog
Posted 21 Jul 2021

Tagged as

Stats

851 views

Row Update After SharePoint File Upload

Rate me:
Please Sign up or sign in to vote.
2.00/5 (1 vote)
21 Jul 2021CPOL1 min read
This post do not cover the steps required to configure SharePoint for document storage with Model-Driven App.

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.

Image 1

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

Image 2

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:

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

Image 3

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:

C#
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.

Image 4

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.

Image 5

Image 6

Lets test the Flow after turning it on.

Image 7

Image 8

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

YawerIqbal
Software Developer (Senior)
Australia Australia
Developer

Comments and Discussions

 
-- There are no messages in this forum --