Click here to Skip to main content
15,860,859 members
Articles / Productivity Apps and Services / Sharepoint

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 2.1K  
How to update row in Dataverse table after file is uploaded to SharePoint
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.

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

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

    Image 3

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

  3. 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:

    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 explained this expression.

    Image 4

  4. 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.

    Image 5

    Image 6

    Let's 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)


Written By
Software Developer (Senior)
Australia Australia
Developer

Comments and Discussions

 
-- There are no messages in this forum --