1

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.

Fowl
  • 4,940
  • 2
  • 26
  • 43
Naveen Singh
  • 395
  • 1
  • 3
  • 17

1 Answers1

1

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}));
Fowl
  • 4,940
  • 2
  • 26
  • 43
Ken Adams
  • 70
  • 1
  • 1
  • 7
  • Does this still work if there are items in the gallery that you don't want to take the text from, e.g. buttons? – J. Mini Mar 07 '23 at 20:41