I am trying to create dynamic input components in the power apps for that I have used Vertical Gallery, and Within that vertical gallery I have a Horizontal container to align the inputs properly, and then I have several inputs under it. I am trying to get the input values from the gallery using "ForAll" loop but I am getting the value of the last Item only.
Below is the structure of the gallery
DynamicComponentsGallery
---- HorizontalContainer
---- ---- Input1Text
---- ---- Input2Date
---- ---- Input3Text
---- ---- AddNewElementToGalleryButton
suppose I have 2 rows In my gallery and I have inserted the records like this
Test1Rec1 20/08/2022 Test1Rec2
Test2Rec1 12/12/2022 Test2Rec2
Every time I try to fetch the record using "ForAll"
ForAll(DynamicComponentsGallery.AllItems, {
input1 : Input1Text.Text,
input2 : Text(Input2Date.SelectedDate, DateTimeFormat.ShortDate),
input3 : Input3Text.Text,
});
I Always get 2 record with the values
Test2Rec1 12/12/2022 Test2Rec2
Test2Rec1 12/12/2022 Test2Rec2
Same Goes for any number of records.
Considering that I have a gallery with 2 items and each item has a textbox for the user to input some data. Here's how I would have on the button:
// clear the collection to avoid accidental clicks on the button
Clear(ColOutput);
// ForAll loop running on the gallery to collect each textbox response in the collection
ForAll(Gallery.AllItems, Collect(ColOutput, {TextboxOutputs:TextInput.Text}));