In this Power Platform training session, Matt Peterson of Pragmatic Works revisits the Patch function and demonstrates how it can be used to create new records in Power Apps without relying on traditional forms. This approach provides greater flexibility in app design and allows developers to fully control the layout and behavior of their input screens.
Matt Peterson explains that while forms in Power Apps are convenient and easy to use, they come with limitations. Developers can adjust layouts and column structures, but overall customization remains restricted. The Patch function offers an alternative by allowing developers to design fully custom screens with input controls placed anywhere.
This flexibility is especially useful when building applications that require a unique user interface or when form-based layouts do not meet specific design requirements.
In the demonstration, Matt Peterson walks through an application designed to capture park inspection data. Instead of using a form, the app uses individual input controls such as text fields and date pickers placed freely across the screen.
Even without a form, developers can still configure default values for these controls. Examples shown in the video include:
This ensures a smooth user experience while maintaining flexibility in design.
Matt Peterson breaks down how the Patch function works when creating a new record. The structure of the function includes three main components:
Each field in the data source must be mapped to a corresponding control in the app. For example:
A key concept highlighted in the video is ensuring that data types match between the app and the data source. Matt Peterson demonstrates a scenario where a numeric column receives a text value, which causes an error.
To resolve this, the Value() function is used to convert text into a numeric format. This step is critical when working with SQL tables or other structured data sources.
Once the Patch function is implemented, the app uses navigation logic to return users to a main screen where they can verify that the record has been successfully created. Matt Peterson emphasizes the importance of referencing the correct screen name to avoid navigation issues.
This validation step ensures that users can immediately confirm their input and that the Patch function is working as expected.
One common issue with custom Patch implementations is that input values remain populated after submission. This behavior overrides default values and can lead to confusion for users when creating new records.
To address this, Matt Peterson recommends using the Reset() function within the screen’s OnVisible property. This approach clears previous inputs and restores default values whenever the screen is opened.
Benefits of using Reset include:
Matt Peterson concludes the session by reinforcing the advantages of using Patch for creating records in Power Apps. While it requires more coding compared to forms, it offers significantly greater control and flexibility.
This session serves as a strong foundation for developers looking to move beyond forms and build more dynamic Power Apps solutions. Future lessons expand on how Patch can also be used to update existing records and handle more advanced scenarios.
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.