When working with Patch() in Power Apps, I often see developers writing code like this:
Many Power Apps developers use:
Patch(
List,
LookUp(List, ID = varRecord.ID),
{ Title: "Updated" }
)
However, if you already know the record ID, you can simply use:
Patch(
List,
{ ID: varRecord.ID },
{ Title: "Updated" }
)
Or, even better, if you already have the full record:
Patch(
List,
varRecord,
{ Title: "Updated" }
)
Why?
Using the record or record ID directly offers several advantages:
Avoids an unnecessary LookUp()
Reduces data source calls
Improves performance
Keeps your code cleaner and easier to maintain
Best Practice
Follow these guidelines when using Patch():
Have the full record? → Pass the record.
Only have the ID? → Use { ID: RecordID }.
Don't have the record? → Use LookUp().
Summary
Avoiding unnecessary LookUp() calls when using Patch() is a simple optimization that can improve the performance and maintainability of your Power Apps. Passing the existing record or its ID directly reduces data source calls, resulting in cleaner and more efficient applications, especially in large Power Apps solutions.