
Announcements
I don't know if PowerApps is just awful or if I am missing something obvious, but I just cannot figure this out.
I have a PA with a location combo box. Users can select one or multiple locations. There are then a bunch of other fields that they fill out as well. I have a button at the end that I want to, when pressed, create one new record in a SP list for each location selected in the combo box, each having the same values for all the other fields.
So for example, if someone filled out the fields as follows:
Locations: Main Street, Broad Street, 1st Street
Date: 1/2/2024
Contact: John Smith
Phone: 867-5309
It would create three records in SP:
Main Street | 1/2/2024 | John Smith | 867-5309
Broad Street | 1/2/2024 | John Smith | 867-5309
1st Street | 1/2/2024 | John Smith | 867-5309
How on Earth do I accomplish this? It seems like it should be a common/basic command, but if it is I am blind.
Hi @DeanM1985 ,
To achieve this in PowerApps, you can use the Patch function to create records in your SharePoint list for each selected location. Assuming you have a SharePoint list called "YourSharePointList" with fields: Location, Date, Contact, Phone. Get the selected locations from the combo box.
Set(selectedLocations, ComboBox_Locations.SelectedItems);
// Loop through each selected location and create a new record in the SharePoint list
ForAll(selectedLocations,
Patch(
YourSharePointList,
Defaults(YourSharePointList),
{
Location: ThisRecord.Value, // Assuming the combo box items are in a column called Value
Date: DatePicker_Date.SelectedDate,
Contact: TextInput_Contact.Text,
Phone: TextInput_Phone.Text
}
)
);
Make sure to adjust the field names and control names according to your app. The key is to use the 'ForAll' function to iterate through the selected locations and use 'Patch' to create a new record for each location in the SharePoint list.
Thanks!!!
Please consider marking my response as the accepted solution if it successfully resolves your concern. If you found the information beneficial in other aspects, kindly express your appreciation by giving it a thumbs-up.