Patch Function in Custom Pages Power Apps
In Power Apps, you can create a Custom Page to leverage the Canvas App capabilities inside Model Driven App. In this post you will learn how to CREATE or UPDATE Dataverse records from custom page.
Create a custom page inside your solution with a gallery connected to Contact table, another gallery to display Rate Of Interest table.
Take a button and write the PowerFX given below. The scenario is, the custom page should display 3 gallery, one customer data, another rate of interest data and third investments data.
When a user select an item from Rate of Interest gallery and select a customer from customer gallery, a new investment record should be created in Dataverse.
The below is the UI designed for the custom page and galleries are connected to respective tables.
On the button use below PowerFX.
Patch(
Investments,
Defaults(Investments),
{
Type: If(
GALroi.Selected.Label3.Text = "Fixed Deposit",
'Type (Investments)'.'Fixed Deposit',
GALroi.Selected.Label3.Text = "Recurring Deposit",
'Type (Investments)'.'Recurring Deposit'),
Amount:800,
Name:"Investment for " & galCustomer.Selected.'Full Name',
Customer:galCustomer.Selected,
'Rate of Interest':ROI.'8.3',
'Tenure in months':30
}
);
Notify("Investment created for the selected customer.")
Publish the Custom Page and Add the page inside model driven app and publish both to test. Now test the app.