Return to Power Automate and create our new Update Service Instant flow. We will use the following components:

  • Trigger – Power Apps – When a Power Apps calls a flow (V2).
  • Scope – Try
    • Action – Dataverse – Update a row
    • Action – Response – rename as “Successful Response”
  • Scope – Catch (run after Try failed)
    • Action – Response – rename as “Failed Response”

For our Trigger, we should add the following parameters

  • Text – ServiceID, Details
  • Number – AirFilter, Battery, BrakeFluid, Brakes, Exhaust, Oil, Steering, Suspension, Tyres
  • Yes/No – ServiceComplete

Pay attention to the order of our parameters.

Next, expand the Update a row action and complete as follows

  • Table name – Services
  • Row ID – ServiceID (input parameter)
  • Air Filter – AirFilter (input parameter)
  • Battery – Battery (input parameter)
  • …etc repeat for all parameters passed in including Details and Service Complete

Update the Successful Response action to set Status Code to 200; update the Failed Response action to set Status Code to 500. Save and publish our flow and add to the solution as before.

Return to our canvas app and add the Update Service flow.

Lastly, we update the OnSelect property of our Save button to run our Update Service flow, passing in the values of our controls:

UpdateService.Run(
galServices.Selected.ServiceID,
sldAirFilter.Value,
sldBattery.Value,
sldBrakeFluid.Value,
sldBrakes.Value,
sldExhaust.Value,
sldOil.Value,
sldSteering.Value,
sldSuspension.Value,
sldTyres.Value,
txtServiceDetails.Text,
tglServiceComplete.Value);
ClearCollect(MyWorkload, ServiceWorkload.Run());

Then we refresh the Gallery items by calling ClearCollect(MyWorkload, ServiceWorkload.Run()).

Now we can remove the Services dataset from our canvas app and not worry about how our application will perform as the Services table grows over time!

Recap on what we’ve learned:

  • The User(), Today() and Filter() functions.
  • Using Dataverse Views to filter datasets.
  • Adding Power Automate flows to a canvas app to fetch data.
  • Using FetchXML to perform cross table queries.
  • Adding Power Automate flows to a canvas app to update records.

Pages: 1 2 3

3 responses to “Building Canvas Apps Part 4: Filtering Datasets and Delegation with Power Automate”

  1. Building Canvas Apps Part 5: Working with larger datsets – Pagination and Filtering – Power Platform Pete Avatar

    […] our last post we learned how to use Power Automate Instant flows to fetch data for our Vehicle Servicing app. We […]

    Like

  2. Working with APIs Part 1: Creating a test API – Power Platform Pete Avatar

    […] it was in the second post, but we had issues when the size of the datasets increased. In the fourth post, we introduced the idea of delegation, using Power Automate flows to fetch the data we required […]

    Like

  3. Creating Custom Pages for Model-driven Apps – Power Platform Pete Avatar

    […] how we can call Power Automate flows from our app and then display the results on screen (see this post for a reminder), so that approach is already understood, but what about model-driven […]

    Like

Leave a comment