Hi all,
Apologies in advance if this has already been discussed; I've been looking through the forums for the past hour for a solution but no luck so far!
I'm trying to patch a gallery to a SQL table, however my patch command seems to be incorrect. This is my current code:
ForAll(
Collection,
Patch(
SQLTable,
{
UserName: gUsername.Text,
IBAN: gIBAN.Text,
Bank: gBank.Text,
Currency: gCurrency.Text,
Mandate: gMandate.Text,
UserRole: gUserRole.Text,
Limit: Value(gLimit.Text),
Note: gNotes.Text,
RequestedBy: User().FullName,
DateRequested: Now()
}
)
)
The command is patching the correct number of records into the SQL Table, (As the number of records in the collection can vary based on a user's requirement), however row in SQL has the same details. It appears as though the first record in my collection is being read but all subsequent rows are just repeating the details of the first record. For example, my command will create two records for the below in SQL, however the second record's data will just be a duplicate of the first:
Curious as to whether anyone else has had this problem? I'm new to PowerApps so suspect it's a silly mistake on my end but any help with this would be greatly appreciated!
Many thanks,
Miles.
Thanks for your help Prstork1, after amending my patch statement to include Default as suggested by yourself I realised that I was actually patching on Labels instead of the Collection columns themselves. I've updated this and now working successfully so thank you again!
Hi Prstork1,
Thanks for your guidance; I've updated my command to include the missing parameter but I'm still getting similar results.
In SQL my Limit column is correctly pulling through, however my IBAN, Bank and Currency values are duplicated from the first record in my collection/gallery, where as the Note is being applied to the first record where text only exists within the second record?
Collection before Patch command run:
Results in SQL from command:
Would you know of any other issue that could be causing this? Thanks for your patience and help so far.
Miles.
The Second parameter of the patch statement needs to be either defaults(data source); (which creates a new record), or something that identifies the specific record to be patched like a Lookup. You just provide the updated values as a record. So you are missing a parameter.
WarrenBelz
791
Most Valuable Professional
MS.Ragavendar
410
Super User 2025 Season 2
mmbr1606
275
Super User 2025 Season 2