Write an example of a patch function for use in microsoft powerapps
- User
Write an example of a patch function for use in microsoft powerapps
Assistant
Here is an example of a patch function for use in Microsoft PowerApps:
Patch( Orders, LookUp(Orders, ID = SelectedOrder.ID), { Status: "Shipped", ShipDate: Today() } )This patch function updates the selected order in the Orders data source. Specifically, it:
- Orders - Specifies the data source table to update, in this case the Orders table
- LookUp - Gets the record from the Orders table that matches the currently selected order's ID
- {Status, ShipDate} - Sets the Status field to "Shipped" and the ShipDate to the current date/time for the matched record
So this patch would update the status of the selected order to "Shipped" and set the ship date to today's date.
Some key things to note about Patch:
- It updates existing records, it does not insert new ones
- The second argument finds the record to update
- The third argument sets the fields/values to update
So in this way you can use the Patch function to selectively update records in a data source in PowerApps.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.