Matt Peterson walks us through using the Patch function in Power Apps to update records without relying on forms. This tutorial focuses on scenarios where developers need to update records directly from galleries or through actions like soft deletes, making it a practical approach for building Power Apps without traditional forms.
Power Apps offers a powerful function called Patch that enables developers to modify or create records without the need for a form. In this tutorial, Matt demonstrates how to use this function to update records in the DataVerse environment, specifically to perform soft deletes and update status values.
Matt begins by showing how to handle a common scenario: updating a record’s status to inactive (soft delete) without removing it from the database. The steps to do this are outlined as follows:
Patch function to update the selected record’s status field to 'inactive' rather than deleting it.To begin with the Patch function:
Matt demonstrates this with the following formula:
Patch(PTORequestTable, SelectedRecord, {Status: {Value: "Inactive"}})
Once the Patch function is applied, the status of the selected record changes to 'inactive,' and the record disappears from the gallery, simulating a soft delete. This method is useful for preserving historical data while keeping the interface clean and user-friendly.
In addition to updating the record, Matt also shows how to filter the gallery to display only active records. By applying a filter based on the record status, users will only see active records in the gallery:
Filter(PTORequestTable, Status.Value = "Active")
This filtering ensures that inactive records are not displayed in the gallery, enhancing the user experience.
Matt goes on to show another common use case for the Patch function: updating a record's approval status. For example, when a manager approves or rejects a PTO request, the status can be updated without using a form.
To implement this, Matt adds a button to the gallery, and when clicked, the button triggers a Patch function to update the PTO request’s status to either 'approved' or 'rejected.'
Patch function to update records based on user actions.Matt concludes by encouraging viewers to experiment with the Patch function to make their Power Apps more efficient and dynamic. Additionally, Pragmatic Works offers virtual mentoring services for developers looking to refine their apps. Matt invites viewers to leave comments or suggest future topics for upcoming tutorials.
Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on Power Apps and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.