Introduction
While working with Power Apps and SharePoint, developers often face unexpected issues when saving data using the Patch() function.
Common problems include:
Duplicate records getting created
Records not updating correctly
Patch silently failing
Wrong record getting modified
Form submission working but Patch not working
In this article, we will explore a real-world scenario where Patch() creates duplicate records instead of updating the existing record — and how to fix it properly using best practices.
Real-World Scenario
You have a SharePoint list named:
ProjectRequests
Columns:
ID (System generated)
Title (Single line of text)
EmployeeID (Single line of text)
ProjectName (Single line of text)
Status (Choice)
RequestDate (Date)
You want to:
Create a new record if it does not exist
Update the record if it already exists
The Problem – Duplicate Records Getting Created
You wrote this formula:
Patch(
ProjectRequests,
Defaults(ProjectRequests),
{
Title: TextInput_Title.Text,
EmployeeID: TextInput_EmpID.Text,
ProjectName: TextInput_Project.Text,
Status: Dropdown_Status.Selected.Value,
RequestDate: Today()
}
)⚠️ Issue:
Every time the user clicks Save, a new record is created, even when updating.
Why?
Because Defaults(ProjectRequests) always creates a new record.
Understanding Patch Behavior
Patch() requires:
Patch(DataSource, BaseRecord, ChangeRecord)If BaseRecord is:
Defaults(DataSource)→ creates new recordGallery.Selected→ updates existing recordLookUp()→ updates matched record
Correct Approach – Update If Exists, Otherwise Create
Step 1: Check If Record Exists
We assume uniqueness based on:
EmployeeID + ProjectName
Use:
Set(
varExistingRecord,
LookUp(
ProjectRequests,
EmployeeID = TextInput_EmpID.Text &&
ProjectName = TextInput_Project.Text
)
);Step 2: Conditional Patch
Now write:
If(
IsBlank(varExistingRecord),
Patch(
ProjectRequests,
Defaults(ProjectRequests),
{
Title: TextInput_Title.Text,
EmployeeID: TextInput_EmpID.Text,
ProjectName: TextInput_Project.Text,
Status: Dropdown_Status.Selected.Value,
RequestDate: Today()
}
),
Patch(
ProjectRequests,
varExistingRecord,
{
Title: TextInput_Title.Text,
Status: Dropdown_Status.Selected.Value,
RequestDate: Today()
}
)
);Now:
If record exists → Update
If not → Create
✅ No duplicates
✅ Controlled logic
✅ Clean behavior

Join the conversation! Your thoughts help the community grow.