cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted

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
Highlighted
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
Highlighted
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!

Highlighted

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

Highlighted

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

Highlighted

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

Highlighted

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

Radu Gruian [MSFT] ** PowerApps Staff
Highlighted

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.

Highlighted

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

 

Highlighted

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,928)