I have a Power App connected to a SQL database.
I have the following code for either inserting new records or updating an IsApproved field on existing records - currently the insert works but the update doesn't.
ForAll(
colShiftReg,
If(
IsBlank(ThisRecord.ShiftRegisterId),
Patch(
ShiftRegister,
Defaults(ShiftRegister),
{
SupervisorId: ThisRecord.SupervisorId,
DepotId: ThisRecord.DepotId,
ShiftDate: SR_dtp_Shift_Date.SelectedDate + Time(Hour(Now()), Minute(Now()), 0),
ShiftDetailsId: ThisRecord.ShiftDetailsId,
OperativeId: ThisRecord.OperativeId,
Hours: ThisRecord.Hours,
ShiftType: ThisRecord.ShiftType,
Enhancement: ThisRecord.Enhancement,
Comments: ThisRecord.Comments,
ContractId: ThisRecord.ContractId,
IsApproved: true,
IsDeleted: ThisRecord.IsDeleted,
RegisterId: GUID(varRegisterId)
}
),
Patch(
ShiftRegister,
LookUp(ShiftRegister, ShiftRegisterId = ThisRecord.ShiftRegisterId),
{
IsApproved: true
}
);
Notify("Patch completed for Id" & ThisRecord.ShiftRegisterId, NotificationType.Information)
)
);
I have added the Notify to see if there is an id for the update - & there is.
I created a Test button with this code in the OnSelect
Patch(
ShiftRegister,
LookUp(ShiftRegister, ShiftRegisterId = 3284),
{
IsApproved: true
}
)
I used the ID from the Notify and it updated the record fine.
I have been going round and round in circles and would appreciate any help.
Thanks in advance