cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Coletteb425
Frequent Visitor

Help! Create multiple list items from form

So I am not too sure where to even start with this one. I have an app where i would like to have a form that you could fill in all the details about 10/11 fields which goes into a sharepoint list. One field is customer, i currently have a combo box in there so we can select more than one but currently it just concatenates this so the customer shows "Customer 1, Customer 2, Customer 3" ideally what i would like is for when submitting this form it would create 3 seperate rows in the list with all the information the same but just with one customer name in each. So then afterwards we can put in individual stats that relate to just that partner. 

 

For example: 

Current view:

Computer screen | 12/08/19 | Colette | Customer 1, Customer 2, Customer 3

 

What i would like:

Computer screen | 12/08/19 | Colette | Customer 1

Computer screen | 12/08/19 | Colette | Customer 2

Computer screen | 12/08/19 | Colette | Customer 3

 

Hopefully that makes sense any ideas? 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @Coletteb425 ,

I think you could create a collection that is the same as table2 and then update with the data of the collection.

For example:

ClearCollect(test,
RenameColumns(
AddColumns(Combo box1.SelectedItems,
"column1","Computer screen","column2","12/08/19","column3","Colette"
), //create a collection that is same as the table that you want
"Value",
"customer" //the value of combo box's fieldname is Value by default, change it to its fieldname in the list
);
Collect(listname,test) //update the list with the data of the collection

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Jeff_Thorpe
Super User
Super User

You could be able to loop through the selected customers using ForAll and use Patch() to create a new record for each customer.

 

Since I don't know all the details of the Form and the fields/input controls used, I can't give you a great example but in general it would like something like this:

 

ForAll(Customer.SelectedItems, Patch(SPList, Defaults(SPList), {Customer:Results , Title:InputControls, ......}))



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
v-yutliu-msft
Community Support
Community Support

Hi @Coletteb425 ,

I think you could create a collection that is the same as table2 and then update with the data of the collection.

For example:

ClearCollect(test,
RenameColumns(
AddColumns(Combo box1.SelectedItems,
"column1","Computer screen","column2","12/08/19","column3","Colette"
), //create a collection that is same as the table that you want
"Value",
"customer" //the value of combo box's fieldname is Value by default, change it to its fieldname in the list
);
Collect(listname,test) //update the list with the data of the collection

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Haze
Frequent Visitor

I am having a very similar problem, I need to use patch() to create multiple list items in one click but, I want one column to be unique in each record. This value will be selected out of the combobox. The current issue is getting the patch to write unique values.

Below is an oversimple example

Date: Today()

Name: TextInput.Text

ForAll(ComboBox_Tasks.SelectedItems,Patch('SPList',Defaults('SPList'), {'Name': Name_Input_1.Text},{'Evaluator': Evaluator_Input_Txt_1.Text},{'Qualification Date':Date_Completed_4.SelectedDate},{'Expiration Date': DateAdd(Date_Completed_4.SelectedDate,3,Years)}, {'Task Name': ???

How would I have it fill for each selected item in the combo box?

@Jeff_Thorpe 



Coletteb425
Frequent Visitor

So I managed to do this in the end @Haze you are basically there you just need the one that is repeated to bring back the result so I assume task name is the one you are selecting in ComboBox so you just need to put either result in or name of the data source that the combobox is pulling from. 

ChadStephens96_0-1652822597731.png

I have a form where I want a new record for each person with all other data matching. Where would I write the patch?

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,659)