0

I have a gallery that repeats its contents. It has one text input for a person's name and another for their email. Users may click a plus icon (the icon is not in the gallery) to produce a new row that has both of these text inputs. They can click the plus icon as many times as they like, and it will produce a new row each time. I believe the technical term for such a set up is "repeating table".

My hope was that I could use ForAll(galleryName.AllItems, [...]) to loop through each of these text inputs and write each pair as a new row in my back end SharePoint List. However, it appears that .AllItems loops through the members that make up the gallery rather than the elements that the user sees. For example, I believe that a repeating table with 100 repetitions of its row would have the same number of items in galleryName.AllItems as a repeating table that only had its original row.

Is there any way to write a loop that loops through the members of a gallery and respects the repetitions? My ultimate goal would be to write some code like this

ForAll(galleryName.AllItems As gal, //Doesn't work because AllItems isn't what I want.
    Patch('My SharePoint List',
           Defaults('My SharePoint List'),
           {Name: gal.txtInputThatHoldsTheName.Text, Email: gal.txtInputThatHoldsTheEmail.Text}))
J. Mini
  • 1,868
  • 1
  • 9
  • 38

1 Answers1

1

One idea would be to have a hidden label (or any other control) that stores the current state of each row, e.g. an existing row would have the label with the text "existing"/empty and any new rows added by clicking the + sign would be "New".

Then in your ForAll, you'd filter the gallery where the YourLabel.Text = "New"

ForAll(
    Filter(galleryName.AllItems, YourLabel.Text = "New"),
    Patch('My SharePoint List',
    Defaults('My SharePoint List'),
    { 
        Name: txtInputThatHoldsTheName.Name, 
        Email: txtInputThatHoldsTheEmail.Email 
    }
    )
)

You don't even need to use gal.txtInputThatHoldsTheName for it to work, simply use the ControlName.Text / ControlName.Value / ControlName.Selected.Value. The label might need to be visible but you can have the height set to 0

Murilo Santana
  • 615
  • 1
  • 7
  • 13
  • That's the weird thing. `ControlName.Text` is **always** blank even when I've definitely filled in the text input. – J. Mini Mar 08 '23 at 09:50