cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Insert new entry into SharePoint list

Hi,

 

Long story short is: I'm trying to insert new data into the SharePoint list where I obtain data from. I'm using custom forms so the functionality for the default insert no longer works. My editing still works.

 

Can someone please advise me on a way to do this in lets say an on button press?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

All the required fields need to be specified in a Collect. The ones that are not required by SP can be ommitted. Some thoughts:

 

  • In general not all fields are required, and what is/isn't required is something that is defined by the SP list itself.
  • Please double check and make sure that the correct types are used. For example, if your list accepts text values but you pass in numerics, or viceversa, this will typically result in a runtime error that PowerApps shows as a red "squiggle" underline.

 

Do any errors show up on the button/visual after you press? (after OnSelect is re-evaluated)

 

 

 

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

10 REPLIES 10
rgruian
Power Apps
Power Apps

You can insert using PowerApps language functions, for example Patch or Collect:

 

    Patch(datasource, row_to_change, record_with_changes)

    Collect(dataSource, new_row)

 

Since you are using a custom form, you will need to assemble the row yourself. (non-custom forms do this automatically on your behalf):

 

    Collect(MySPList, { ID: input1.Text, Name: input2.Text, Age: slider3.Value, ........ })

 

If you need to edit an existing row, use Patch:

 

    Patch(MySPList, row_to_change, { Name: "new name" })

 

Any one of these operations can be performed from an action, such as the OnSelect property of a button:

 

    SubmitButton.OnSelect = Collect(MySpList, { Id: 2, Name: "Joe" })

 

I hope this helps.

Radu Gruian [MSFT] ** PowerApps Staff
Anonymous
Not applicable

Hey,

 

Thanks for the clear and consice answer.

 

I tried your suggestion but with no luck. Are you required to enter all the columns manually? "Title" is a required field.

 

I tried the following:

OnSelect = Collect(list, {ID: (Last(list.ID).ID +1), Title: "test", Week: (Last(list.Week).Week + 1)})

 

I then tried to simplified to:

OnSelect = Collect(list, {ID: 9, Title: "test", Week: 9})

 

Any suggestions to why this isn't working? 

 

Cheers!

All the required fields need to be specified in a Collect. The ones that are not required by SP can be ommitted. Some thoughts:

 

  • In general not all fields are required, and what is/isn't required is something that is defined by the SP list itself.
  • Please double check and make sure that the correct types are used. For example, if your list accepts text values but you pass in numerics, or viceversa, this will typically result in a runtime error that PowerApps shows as a red "squiggle" underline.

 

Do any errors show up on the button/visual after you press? (after OnSelect is re-evaluated)

 

 

 

Radu Gruian [MSFT] ** PowerApps Staff

ID is a field that is generated by SharePoint. So, you should not provide a value for that. You need to specify values for all required fields.

 

Doing 

Collect(list, {Title: "test", Week: 9}) should work.

 

You could also do

Patch(list, Defaults(list), {Title: "test", Week: 9}) to ensure you get the default values that are specified on SharePoint for certain fields.

 

Thank you

Murali

Can We send another collection to sharepoint list ? For Eg : Collect(MySPList,MyAnotherCollection)

Yes, that should work, as long as the schemas match.

Radu Gruian [MSFT] ** PowerApps Staff

Hello , I have only one column in my sharepoint list which is Single Line Data Type and my collection also has only one column but still I am unable to save all my data from a collection to a sharepoint List.

Can you help understand how to match the values from the form and my sharepoint list ?

 

Nerver mind. Figured it out.

 

Do you know what's the relationship between a form a browse gallery ?. If I don't specify a Browse Gallery my from shows up as blank. 

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (4,551)