Perform CRUD operations on expanding datasets in SharePoint (Part 1)

This post is a part of a series. If you are new to this use case, please check my previous post to understand the problem and solution design.

In this post, we will discuss how to perform CRUD operations on this dataset.

Let’s start..

Here’s our dataset record sample:

{
  "UserID": "SomeID",
  "UserName": "John Doe",
  "Time Entries": [
    {
      "Week": 1,
      "Day": "Sunday",
      "DailyTimeEntries": [
        {
          "Start": "",
          "End": "",
          "Duration": 2.5,
          "Description": "Some Description"
        }
      ]
    }
  ]
}

How to READ this data inside PowerApps

  1. Open PowerApps, add a gallery control
  2. Connect it to your “User Time Entries” SharePoint list

3. When we try to get the Time entries data, Power Apps recognizes this as a string and it is complicated to deserialize this string value. However, we can use PowerAutomate for this task.

When we click a button, PowerAutomate can fetch the relevant record, deserialize and send the object back to Power App.

Use below steps :

For schema, copy the field value and paste it in “Generate from sample” section. This will auto generate the schema.

When we pass the SharePoint list item ID from the canvas app, flow will fetch the Time entries field value and send it after structuring the response according to our schema.

Save flow and let’s go back to the app

4. Now we can execute this flow from the app by passing the list Item ID as a parameter and capture response value in a global variable (ScheduleObj)

After running the flow, we can see the nested table in schedule object.

5. Add new screen and a gallery to show time entries. Set “Items”value as”ScheduleObj”

6. Add another sub gallery inside main gallery. This sub gallery should only show daily records for each day in the main gallery.

Items = LookUp(ScheduleObj,Day=ThisItem.Day&&Week=ThisItem.Week).DailyTimeEntries

Done.

So far we have created an expanding dataset in SharePoint and viewed the data within our PowerApp.

Next, let’s see how we can create new records in this dataset.

Happy Learning!



Categories: Power Automate, PowerApps, SharePoint

Leave a comment