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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Duplicate records runn...
Power Apps
Answered

Duplicate records running Gallery ForAll function

(0) ShareShare
ReportReport
Posted on by 37

I read on Google it should be a bug, but not sure the truth.

 

It is a responsive App. I have a container inside a gallery where I put my controls. 
The problem is when I call the ForAll function, instead saving all records from the gallery it is duplicating the last record.

If I do the same without a container (only the Gallery) it works.
Checking the pictures you can see the container inside the gallery, then how it is organized on the screen Treeview, the result (duplicated of the collection "colAllDetails", and finally the body of the function associated to a OnSelect of a button.

Not sure, but as the controls are inside the Container, it can be the reason of the issue. I checked many tutorials on how to create responsive galleries and almost all of then are using the same approach, but none of them run a ForAll.
Does anyone can help me on that?

 

The code on the OnSelect of the button is below:


Clear(colAllDetails);
Select(Gallery4);
ForAll(
   Gallery4.AllItems,
   Collect(
      colAllDetails,
      {
          Name: TextInput6.Text,
         LastName: TextInput7.Text,
         DOB: DatePicker1.SelectedDate,
        RelationshipTo: Dropdown2.SelectedText,
        BookingReference:TextInput10.Text
      }
)
)

Thanks.

pax-dups.png
pax-CNTR.png
pax1.png
Categories:
I have the same question (0)
  • Verified answer
    cha_cha Profile Picture
    4,932 Moderator on at

    Hello @RickMclamb365 

     

    I have tried your case and I can confirm that ForAll cannot retrieve row values of controls inside a container. You were right in your suspicion.

     

    Had a play with it and found a work around.

    You can add invisible Label that can reference their value to the current row's entry. Below is an example:

     

    cha_cha_0-1685365033630.png

     

    Your ForAll code will look like this:

    ForAll(Gallery4.AllItems,
     Collect(
     colAllDetails,
     { 
     Name: LabelFirstName.Text,
     LastName: LabelLastName.Text,
    	 DOB: DatePicker2.SelectedDate,
     RelationshipTo: LabelRelationship.Text,
     BookingReference: LabelBookingReference.Text
     }
     )
    )

     

    As for the DatePicker, you can add a hidden date picker outside the container so you use that as reference.

    cha_cha_1-1685365402549.png

     

  • Verified answer
    RickMclamb365 Profile Picture
    37 on at

    Many thanks @cha_cha working perfectly.

    Cheers.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

#2
11manish Profile Picture

11manish 224

#3
Valantis Profile Picture

Valantis 181

Last 30 days Overall leaderboard