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

Community site session details

Session Id : 4ftYq52LQPQN7J1pYieJIt
Power Apps - Building Power Apps
Answered

For All & Patch command creating duplicate data

Like (0) ShareShare
ReportReport
Posted on 1 Nov 2020 13:23:34 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.

 




  • Community Power Platform Member Profile Picture
    on 01 Nov 2020 at 14:56:13
    Re: For All & Patch command creating duplicate data

    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!

  • Community Power Platform Member Profile Picture
    on 01 Nov 2020 at 14:50:26
    Re: For All & Patch command creating duplicate data

    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.

     

  • Verified answer
    Pstork1 Profile Picture
    67,165 Most Valuable Professional on 01 Nov 2020 at 13:40:20
    Re: For All & Patch command creating duplicate data

    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.

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete