Patch SharePoint List in Canvas Apps

Introduction

As you use Canvas Apps more your less likely to use standard forms which means you won’t be able to use simple functions like ‘SubmitForm(FormName)’ and more likely to adopt functions like ‘Patch’. This can be quite daunting at first but have a lot of advantages  

Benefits of Patch Vs Submit Form

Submit FormPatch
Simplicity – Straight forward to use, almost no coding.Flexibility – Allows you to update only the specific columns you want rather than the whole form.
Built-in Validation – It automatically validates data for required fields and data typesEfficiency – Minimalises the amount of data that is needed to be transmitted making it faster to update
Ease of Use – Submits all the field on the form for the entire recordCustom Logic – You can add custom logic to specific fields giving more control of the data that is transmitted

In our SharePoint list we have created the below columns and will show you how to patch each one of them:

  • Text
  • Choice
  • Multi-Choice
  • Date
  • Person
  • Number
  • Yes/No
  • Hyperlink
  • Image
  • LookUp

For ease of use we have set up a SharePoint List and the columns are named the same as the field type with ‘Field’ at the end:

SharePoint Column NameCanvas App Field Name
TextTextField
ChoiceChoiceField
Multi ChoiceMultiChoiceField
MultiMultiChoiceField
DateDateField
PersonPersonField
NumberNumberField
Yes/NoYesNoField
HyperlinkHyperlinkField
ImageImageField
LookUpLookUpField

Patch New And Update Record

When using SubmitForm function it doesn’t matter if you are adding a new record or updating an existing record the same function applies. When using the Patch function you need to define if you are updating an existing record or adding a new record.

 

Patch New Record

To add a new record the patch function must contain certain elements:

  • Function Name
  • Record/ Expression to be patched
  • Fields to be patched

Below is a simple example patching Order Name and Order ID to the Orders SharePoint List

				
					Patch(Orders,Defaults(Orders),
{
    Order ID:Value(TxtOrderID.Text),
    'Order Name':TxtOrderName.Text,
    
}
				
			

In this example we are:

  • Initialising the ‘Patch’ Function
  • Selecting the Data source to be patched
  • Defining a new Record  using ‘(Defaults)’
  • Setting data source where the new record needs to be patched to
  • inputting the columns that will be patched

Simple Columns

Some columns are easier to patch than others, below are examples of each of these:
SharePoint Column NameCodeDescription
TextText:TextField.TextSimple text field. Hint: add trim to remove trailing spaces
ChoiceChoice:ChoiceField.SelectedCan patch manual values with Choice: {value: "ChoiceField.Selected.Value"}
Multi Choice'Multi Choice':MultiChoiceField.SelectedItemsPatch multiple items from combo box selection
DateDate:DateField.SelectedDatePatch date from data picker control
NumberNumber:Value(NumberField.Text)patch a number must be validated to number value
Yes/No'Yes/No':YesNoField.ValueChoice value or TRUE or FALSE
HyperlinkHyperlink:HyperlinkField.TextPatched as Text field must be web address and start with http
ImageImage:ImageField.ImagePatch from the image field.
PersonPerson:PersonField.SelectedPatch from selected person from combobox selected.

The Result

				
					Patch(Orders,Defaults(Orders),
{
    Text:TextField.Text,
    Choice:ChoiceField.Selected,
    'Multi Choice':MultiChoiceField.SelectedItems,
    Date:DateField.SelectedDate,
    Number:Value(NumberField.Text),
    'Yes/No':YesNoField.Value,
    Hyperlink:HyperlinkField.Text,
    Image:ImageField.Image,
    Person:PersonField.Selected
})
				
			

Patch Complicated Column Types

We have shown how to patch column that are generated directly from the data source but what if you you didn’t have that data or patching manual values or from a different data source.

Choice Field

Lets say we have a combobox with the values ‘Apple’, ‘Pair’ and Orange as below we can put this into an array within the items properties on the combo box like below:

and this would work in the patch function, but lets say we didn’t want to patch from a combo box but from a text field.

With a SharePoint list we can patch manual choice values:

				
					Patch(Orders,Defaults(Orders),
{
    Choice:{Value:TextInput.Text}
})
				
			

Date Field

For date fields most the time we would be patching from a date control, but what if we wanted to manually input a date? Even if we format it to ISO8601 this still wouldn’t work as it expects a ‘Date’ value not a ‘Text’ value

To do this we can pass it through as a date value 

				
					Patch(Orders,Defaults(Orders),
{
    Date:DateValue("2025/03/23")
})
				
			

To add time we need to also pass through a time value:

				
					Patch(
    Orders,
    Defaults(Orders),
    {
        Date:DateValue("2025/03/23") + Time(21, 30, 0)
    }
);
				
			

Person Column

Probably one of the most complex column types in SharePoint is the Person column type. The User/ Person must first exist in Entra for this to work however you can manually patch a person field. 

To manually patch a person you need to pass some parameters but you only really need the email address to patch.

How about patching the current logged in user? For this we can use the ‘User()’ function:

				
					Patch(Orders,Defaults(Orders),{
    Person:
    {
           '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
           Claims: "i:0#.f|membership|" & User().Email,
           Department: "",
           DisplayName:  User().FullName,
           Email:  User().Email,
           JobTitle: "",
           Picture: ""
        }
    }
);
				
			

Like this post? Why not share it!

LinkedIn
WhatsApp
Facebook
Reddit
X
Email

View more blog posts

Power Automate FormatDateTime Expression

2 min read

Read this blog

Condition Vs Expressions In Power Automate

3 min read

Read this blog

Power Apps Environments

2 min read

Read this blog

Using Environment Variables

4 min read

Read this blog

Get In Touch

Let’s talk. Send us a message, and we’ll help you explore the best Power Platform solution for your business

We can turn your mondain tasks into effective workflows, saving you and your business time and money