Modern Controls Tutorial: Power Apps PATCH Function
Power Apps
Oct 31, 2023 9:00 AM

Modern Controls Tutorial: Power Apps PATCH Function

by HubSite 365 about Reza Dorrani

Principal Program Manager at Microsoft Power CAT Team | Power Platform Content Creator

Citizen DeveloperPower AppsPower SelectionLearning Selection

Unlock your Microsoft Power Apps potential with our comprehensive tutorial on using the Patch function with Modern Controls. Seamlessly insert, update records,

Power Apps PATCH Function Tutorial: Summarised Video Overview

In this practical tutorial delivered by Reza Dorrani, viewers are guided step-by-step on how to effectively use PATCH function in Power Apps. Covering all aspects from using the function to insert or update records in a data source to enhancing the user experience by making the PATCH form screen responsive.More details about PATCH function in Power Apps can be found here.

Table of Contents:

  • 00:00 - Introduction to PATCH function in PowerApps with Modern Controls
  • 00:44 - Scenario in video related to Patch function & modern controls
  • 02:27 - Build your own Form Screen using Modern Controls
  • 08:24 - Set Default values for Modern Controls
  • 11:38 - Patch function usage
  • 16:28 - Validations before Patching using Modern Controls
  • 21:53 - Make PATCH Form screen Responsive
  • 24:40 - READY to subscribe to Reza Dorrani’s channel

The tutorial also incorporates the utilisation of new ValidationState property of modern controls. Reza Dorrani explains how to set values for different SharePoint column types such as Text, Number, Choice, and Multi-select Lookups. As per the tutorial, the extended use of PATCH function combined with modern controls is a game-changer.


These new features ultimately reduce the number of controls applied in your apps, simplifying configuration, enhancing performance and expediting app development. Other topics covered in the tutorial include building your own form screen using modern controls, setting default values for these controls, running validations before PATCHing using these controls, and making the PATCH form screen responsive.

Understanding PATCH Function in Power Apps: The Basics

The main use of the PATCH function is to modify one or more records in a data source. In specific, individual field values are altered without impacting other properties. PATCH can also work in tandem with the Defaults function to generate new records, making it possible to design a single screen for both record creation and editing.
 

NB: PATCH function can be employed to merge two or more records even outside of a data source. For instance, you may want to merge two records identifying both the phone number and location for a certain client, which is demonstrated in this formula:

  • Patch({Name: "Your_client's_name", Phone: "Their_phone_number"}, {Name: "Same_client's_name", Location: "Their_location"})

A Note about Errors Handling in PATCH Function Usage

When updating a data source, there's potential for one or more issues to arise. PATCH return value can be used with IfError and IsError to detect and respond to these errors. The Errors function can also prove useful in identifying and scrutinizing issues.
 

PATCH can also be used to create or modify multiple records with a single call, and when used this way, it returns a table with each record corresponding one-for-one with base and change records. Additionally, multiple change records can be specified, with each presenting new property values that override those in the base record, processed in order from beginning to end.

Examples of PATCH Function Usage

In demonstrating how to modify or create a record, Reza Dorrani used the IceCream data source for his examples. He modified a record in this data source and also created a new one using this formula:

  • Patch(IceCream, Defaults(IceCream), {Flavor: "Strawberry"})

When it comes to resolving ambiguities in PATCH function usage, the As or ThisRecord keyword can be used in the formula. This guarantees that the OrderId in the lookup scope is compared with the OrderId of collection A in the ForAll scope, avoiding any ambiguities.

Final Thoughts

Reza Dorrani’s tutorial offers a comprehensive overview of the functionality and power offered by Power Apps’ PATCH function. When successfully mastered, it provides an innovative way to enhance the user experience, increase development speed, and optimise performance within your applications.Get more insights on Power Apps here.

Power Apps - Modern Controls Tutorial: Power Apps PATCH Function

Learn about Power Apps PATCH function Tutorial with Modern Controls

 

Understanding the Patch function within Power Applications (used only once till now) is quite essential, especially in the context of handling and managing data within other solutions like SharePoint. Patch function, an empowering feature, allows you to perform functions like adding or updating records within your data source flawlessly.

These tutorials typically educate the user on how to integrate the Patch function with modern controls. This integration provides the advantage of easily adding or updating data in a SharePoint List. It leverages the ValidationState property of Modern controls to simplify the process of adding or modifying items in a SharePoint List while ensuring necessary data validations.

The usefulness of this function is not merely limited to the traditional data types (like Text and Number), but it expands to other sophisticated SharePoint column types, including Choice and Multi-select Lookups. This makes it an extremely versatile function to have in your toolset.

According to the tutorial, you can refine your Canvas Applications (used once already) by making your Patch Form Screen Responsive. This is essentially achieved by merging a scrollable Canvas control within a Responsive container. This is a valuable method to boost the user experience.

The application of Modern Controls in your applications (third and final time of using this term) offers a host of benefits. This includes reducing the number of controls utilized in your applications, providing simple configuration, and improving performance. Furthermore, it accelerates the pace of application development, thereby saving time.

Modifying or creating records in a data source is another advantageous feature of the Patch function. This function empowers you to carry out updates that do not require user interaction or updates involving forms spread across different screens. For simple changes, you may wish to use the Edit form control that allows users to fill in a form and directly save changes to a data source. This functionality greatly simplifies data management for the end-users.

The Patch function can be used to modify specific fields of one or more data sources' records without impacting other properties or values. You can also utilize this function to develop a single screen that caters to both creating and updating records. This feature provides an ease of handling data within your application.

You also have the ability to use the Patch function beyond a data source. This function allows you to merge two or more records, particularly beneficial when you want to consolidate information from multiple records into one. A common instance is to combine both the phone number and location details for a customer into a single record.

The function also lets you modify or create a record in a data source or merge records outside the data source. This is achieved by defining a data source, a base record, and one or more change records carrying new property values.

You could also make use of Update function to replace an entire record or Collect function to create a record. Another useful function is UpdateIf, that allows you to change certain properties of multiple records based on a condition.

Keywords

Power Apps PATCH function, PATCH Tutorial, Modern Controls, Power Apps Controls, PATCH function for Modern Controls, Learn PATCH function, Power Apps tutorial, Modern Controls Tutorial, Power Apps modern interface, PATCH function guide