Hi,
I am new to PowerApps and have some issues with using Patch and ForAll. I have a form where a user enters in some information, one of which is a ComboBox with a list of locations and another (invisible) field where the submitted form gets an ID number (DataCardValue3) based on the existing records in an Excel table (ExampleTable1). My goal is that if a user selects 4 sites for examples, 4 new records are created with all of the same information EXCEPT different ID numbers (sequential) and different Location names. My issue is that I am unable to get the correct number of records created, let alone have the data updated. Within the Patch function I didn't include all of the columns of ExampleTable1 but I'd imagine the code is something along the lines of {Name: textboxName.Text , Age: textboxAge.Text}.
For example,
User Inputs into Form3:
Name: Billy House
Age: 34
Location (ComboBox2): New York, Chicago, Paris
Output in ExampleTable1:
| ID | Name | Age | Location |
| 1001 | Joe Pringles | 24 | Tokyo |
| 1002 | Cheddar Chips | 72 | London |
| 1003 | Billy House | 34 | New York |
| 1004 | Billy House | 34 | Chicago |
| 1005 | Billy House | 34 | Paris |
This example only is with 4 columns, but my actual dataset has 20+ columns. Currently the code is only adding the first record and the rest are ignored. Any help with figuring out how to create multiple records and updating only these two fields would be appreciated!
ForAll(
ComboBox2.SelectedItems, //ComboBox2 contains list of locations that user can choose
Patch(
ExampleTable1,
Defaults(ExampleTable1),
{
ID: DataCardValue3 + 1, //DataCardValue3 is where an ID is automatically added to ExampleTable1
Location: ComboBox2.Selected.'Location Name'
},
Form3.Updates,
)
);
Refresh(ExampleTable1);
ResetForm(Form3)