10 Things You Can Do with Patch() — and 3 You Shouldn’t

  • avatar
    Admin Content
  • Apr 07, 2025

  • 26

10 Things You Can Do with Patch() — and 3 You Shouldn’t 

Marcel Broschk
M365 & Power Platform governance specialist in passion with AI
 
 
 
March 28, 2025 

If you’ve been working with Power Apps for any length of time, you’ve probably heard about Patch(). This powerful function is like a Swiss Army knife — it can create, update, and even manipulate data in ways that other functions like SubmitForm() or Collect() just can't match. But like any sharp tool, it has to be used wisely.

In this guide, we’ll walk through 10 practical things you can do with Patch(), and 3 situations where you shouldn’t rely on it. Whether you're working with SharePoint, Dataverse, SQL, or local collections, this guide will help you get the most out of this flexible function.


What is Patch()?

The Patch() function in Power Apps is used to create or modify records in a data source. That could be SharePoint, Dataverse, SQL, Excel, or even a local collection. Unlike SubmitForm(), which works with form controls, Patch() gives you more control — you can define the fields, values, and even conditional logic on the fly.

Syntax Basics

To create a new record:

Patch(DataSource, Defaults(DataSource), {Field1: Value1, Field2: Value2})

To update an existing record:

Patch(DataSource, LookUp(DataSource, ID=123), {FieldToUpdate: NewValue})

It’s flexible and powerful — and often necessary when forms don’t quite cut it.


10 Things You Can Do with Patch()

1. Create a New Record Without a Form

Patch() is perfect for creating records dynamically, without needing to bind every field to a form control.

Patch(Tasks, Defaults(Tasks), {Title: "New Task", Status: "Not Started"})

This is especially useful when your inputs are scattered across the screen or created via automation.


2. Update a Record by ID or Lookup

Need to update a single record based on a unique identifier? Patch() makes it clean and easy.

Patch(Tasks, LookUp(Tasks, ID=123), {Status: "Completed"})

It’s a great way to update records based on user interactions, like clicking a “Mark Complete” button.


3. Partially Update Only Specific Fields

One of Patch()’s strengths is that you don’t need to include all the fields. Just update what you need.

Patch(Tasks, ThisItem, {Priority: "High"})

This avoids overwriting data unintentionally and keeps your updates efficient.


4. Update or Create Based on Condition

Patch() supports a hybrid behavior: you can use it to update a record if it exists or create a new one if it doesn’t.

Patch(Tasks, LookUp(Tasks, ID = varID), {Title: "Updated or New Task"})

This is ideal for upserts — especially when syncing external data.


5. Patch Multiple Records at Once

Need to bulk update a set of items? Wrap Patch() in a ForAll() loop.

ForAll(Filter(Tasks, Status="Not Started"), Patch(Tasks, ThisRecord, {Status: "In Progress"}) )

This is useful for batch processing or workflow-based changes.


6. Patch Collections (Temporary Local Data)

Local collections are great for offline or temporary data, and Patch() can modify them just like server data.

Patch(colCart, LookUp(colCart, ID=3), {Quantity: 5})

This gives you flexibility in building shopping carts, drafts, or offline-first apps.


7. Work with Dataverse and Choice Columns

Dataverse has complex fields like choices or lookups, and Patch() handles them with structure.

Patch(Contacts, Defaults(Contacts), { Name: "Alex", Status: { '@odata.type': "#Microsoft.Dynamics.CRM.OptionSetValue", Value: 100000001 } })

Once you understand the format, it opens up powerful data manipulation options.


8. Use Patch to Handle Hidden Fields or Defaults

When you need to set system or hidden fields (like timestamps or user info), Patch() can help you assign them directly.

powerapps

KopierenBearbeiten

Patch(Logs, Defaults(Logs), { Action: "Delete", Timestamp: Now(), User: User().FullName })

Great for audit trails or automated logs.


9. Patch with LookUp or Defaults Combined

Patch() works well with other Power Apps functions, allowing you to embed logic on the fly.

Patch(Tasks, LookUp(Tasks, ID=taskID), {AssignedTo: LookUp(Users, Email=User().Email)})

This results in cleaner apps and more maintainable logic.


10. Patch User Information or Logged-In Metadata

Need to log user actions or metadata? Use Patch() with User() and Now() for tracking.

Patch(Comments, Defaults(Comments), { Comment: txtComment.Text, CommentBy: User().FullName, CommentTime: Now() })

This is helpful for approval workflows, collaborative input, or activity tracking.


3 Things You Shouldn’t Do with Patch()

1. Don’t Use Patch When SubmitForm Will Do

If you're using a form control, and the goal is to submit all values from it, stick with SubmitForm(). It’s more concise, handles validation automatically, and respects the form’s built-in data card logic. Overusing Patch() in this scenario only adds unnecessary complexity.


2. Don’t Rely on Patch Without Error Handling

Because Patch() executes silently, it’s easy to assume a record was updated successfully — even when it wasn’t. Always use error handling to catch failed operations.

If( IsError(Patch(Tasks, ThisItem, {Status: "Done"})), Notify("There was an error", NotificationType.Error) )

This ensures your app is reliable and easier to troubleshoot.


3. Don’t Patch Large Lists Without Delegation Awareness

When patching SharePoint or Dataverse lists, you're limited by delegation constraints. If you filter large data sets on the client side, only the first 500 to 2000 records (depending on your settings) are processed.

Instead of this:

ForAll(Filter(Tasks, Status="New"), Patch(...))

Use indexed columns or server-side filters to avoid incomplete updates and performance issues.

Tags: Power Apps

Get New Internship Notification!

Subscribe & get all related jobs notification.