Estimated reading time: 4 minutes
PowerApps Patch Function Explained
The Patch function in PowerApps is used to update specific fields in a record in a data source, such as a SharePoint list or a SQL table.
The function takes two main arguments: the data source and the record to update, along with the fields and their new values.
Here’s an example of how to use the Patch function to update a record in a SharePoint list:
In this example, the Patch function is updating the Title and Description fields of the first record in the SharePointList data source to “New Title” and “New Description”, respectively.
The Defaults function is used to specify the record to update, in this case the first record in the list.
The Patch function can also be used in conjunction with other functions, such as the UpdateContext or Collect functions, to update multiple records or to update a record based on user input.
It’s important to keep in mind that if you don’t set the primary key of the record, the patch function will create a new record instead of updating the existing one.
Additionally, you can also use the Patch function to update the records in the collection, for example
This will update the first record in the collection “collData” where columnName = “some value” and change the value of columnName to “new value”.
Examples
Formulas are a key feature in PowerApps that allow you to perform calculations and make logical comparisons on data.
They can be used to create custom expressions, validate data inputs, and control the behavior of app components.
Formulas can be used in various places throughout PowerApps, such as in the properties of controls, in the conditions of rules, and in the behavior of buttons.
The syntax of a formula in PowerApps is similar to that of a spreadsheet formula, and it uses a combination of functions, operators, and values to produce a result.
Functions are predefined formulas that perform specific tasks, such as calculating the sum of a set of numbers or converting a text string to uppercase.
Operators are used to perform mathematical and logical operations, such as addition, subtraction, and comparison.
Values can be numbers, text, true/false, and more.
here are some examples of how to use formulas in PowerApps:
This formula will filter the OrderItems collection to only include items with the same OrderID as the selected order, and then sum the Price field of all those items.
This formula will check if the text entered in the TextInput control is blank. If it is, the formula will return “Please enter a value”, otherwise it will return “Valid input”.
This formula will format the current date and time to show the year, month, day, hour and minutes.
This formula will check the value of the toggle1, if it is on, it will set the value of the variable ‘var’ to ‘on’ else it will set the value to ‘off’.
This formula will check the selected value of the Dropdown1 and if it is equals to “Option1” it will set the visibility of the control to true else it will set to false.