Yes — this is a classic timing issue in Power Apps. The Patch isn’t failing; the selected record is changing before the Patch finishes, so the formula ends up using the new gallery selection.
The safest fix is to store the selected customer in a variable first, then use that variable in the Patch instead of Gallery.Selected.
This way, even if the user clicks another customer immediately, the Patch still updates the correct record.
Example:
// OnSelect of the gallery item
Set(varSelectedCustomer, ThisItem);
Then your Patch should reference the variable, not the gallery:
Patch(
'Customer Notes',
LookUp(
'Customer Notes',
CustID = varSelectedCustomer.CustID
),
{
CustomerNote: txtNote.Text
}
);
This alone usually solves the issue.
If you also want to prevent user interaction while the Patch is running, you can add a simple loading flag:
Set(varSaving, true);
Patch(
'Customer Notes',
LookUp(
'Customer Notes',
CustID = varSelectedCustomer.CustID
),
{
CustomerNote: txtNote.Text
}
);
Set(varSaving, false);
Then:
If(varSaving, DisplayMode.Disabled, DisplayMode.Edit)
Why this happens
Gallery.Selected is not locked at execution time.
If the user clicks another record before Patch completes, Power Apps evaluates the formula again using the new selection.
Using a variable creates a snapshot of the selected record, which prevents race conditions.
Recommended approach
✔ Always store selected records in variables
✔ Never Patch directly from Gallery.Selected
✔ Optionally disable UI during save
This pattern avoids accidental updates and is widely used in production Power Apps.