web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / For All & Patch comman...
Power Apps
Answered

For All & Patch command creating duplicate data

(0) ShareShare
ReportReport
Posted on by

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:

KingRGM_0-1604236855686.png

 

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.

 




Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    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.

  • Community Power Platform Member Profile Picture
    on at

    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:

    KingRGM_1-1604242295644.png

     

    Results in SQL from command:

    KingRGM_0-1604242272799.png

     

     

    Would you know of any other issue that could be causing this? Thanks for your patience and help so far.

    Miles.

     

  • Community Power Platform Member Profile Picture
    on at

    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!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard