How to Update SharePoint List Item Using Power Apps Patch Function?

Recently, I was working on creating login forms using Power Apps, and I encountered a requirement for users to update their passwords if they forget them.

During this process, the passwords stored in the SharePoint list must be updated accordingly.

In this article, I will explain how to update SharePoint list items using Power Apps Patch function.

Update SharePoint List Using Power Apps Patch Function

Power Apps Patch() function helps to create a new record or modify existing records in any data sources like SharePoint list, Excel, Sql, etc.

Syntax: Patch(Datasource, BaseRecord, ChangeRecord)

I have a SharePoint list called Event Registration Form, which stores the details of registered users.

powerapps update sharepoint list item on button click

Refer to the table below, which contains the above SharePoint list column names and their data types.

Column NameType
UserIDSingle line of Text
PasswordSingle line of Text
First NameSingle line of Text
Last NameSingle line of Text
Email AddressSingle line of Text
Phone NumberSingle line of Text
DepartmentChoice
Look at the example below: The Password in the SharePoint list got updated from the Power Apps.
how to update sharepoint list item from power apps

To achieve this, follow the below steps.

1. Create one blank canvas application in Power Apps; on the new screen, add the following controls.

  • Three Text Input controls -For, Email, NewPassword, and Confirm Password.
  • Three Text label controls -For, Email, NewPassword, and Confirm Password.
  • Button Control -To update the password.
  • Icons, if you require them.

Design the screen with the above controls as shown below.

how to update sharepoint list item from powerapps

2. Now, connect with the SharePoint list from the Data in Power Apps navigation.

powerapps update sharepoint list item using patch

3. Provide the formula below in the OnSelect property of the button control.

If(
    txt_NewPassword.Text = txt_ConfirmPassword.Text,
    Patch(
        'Event Registration Form',
        LookUp(
            'Event Registration Form','Email Address'=txt_Email.Text
        ),
        {Password: txt_ConfirmPassword.Text}
    );
    UpdateContext({errorVisible: false}),
    UpdateContext({errorVisible: true})
);
Notify("Password updated successfully", NotificationType.Success);

Reset(txt_ConfirmPassword);
Reset(txt_Email);
Reset(txt_NewPassword);

Here,

  • txt_NewPassword and txt_ConfirmPassword = New and confirmed password text input control names.
  • Event Registration Form‘ = SharePoint list name. And ‘Email Address’ is the column name in that SharePoint list.
  • txt_Email = Text input control name of the email.
  • Password = SharePoint list column name
  • errorVisible = Variable name that can be used only within the screen.
  • Notify() = Displays the message if the condition is satisfied.
  • Reset() = Helps reset the controls after all the conditions.

In the above formula, the If condition first checks whether the new and confirmed passwords are identical.

If yes, the Patch() updates the password based on our entered email. Later, it sends one success notification, resets the email, and confirms password controls. If not, it sets one variable to display the error message.

update sharepoint list using patch powerapps

4. Add one Text label to display an error message. Then, provide the below variable name in the Visible property of the text label.

Visible: errorVisible

Then, provide the message in the Text property of the text label.

Text: "Passwords do not match. Please try again."

5. To convert the text entered in the password field into dots, provide the formula below in the screen’s Onvisible property.

Set(Password_View,TextMode.Password);
powerapps update sharepoint list item using patch

Then, use this Password_View variable in the Mode property of both new and confirmed password text input controls.

Mode: Password_View

6. Save the app and reload it once. Then, it will work properly; see the example below; the text entered into the password fields is converted to dots.

powerapps patch update sharepoint list

7. If you want to see the provided password, put the below formula in the View icon’s OnSelect property.

Set(Password_View,TextMode.SingleLine);

This will convert the dotted password into text.

update sharepoint list from powerapps form

8. Now, save and publish the app. While previewing, If I enter different passwords on the new, confirm password text input controls, it displays an error message.

patch function power apps update record

This way, we can update the SharePoint list items from Power Apps using the patch function.

Additionally, you may like some articles below:

I hope you found this article informative. In it, I explain how to update SharePoint list items from Power Apps.

You can use it as a guide whenever you’re trying to update the datasource records from Power Apps.

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…