How to make the patch function work in PowerApps?

Viewed 114

I am currently working on a powerapps app, and I have multiple pages with forms and different SharePoint lists connected to it. But every code I tried for submitting the data to the SharePoint doesn‘t seem to be working. Does anyone have any ides?

Patch('5S Fragen_1';varFormData1; Form1.Updates; Form3.Updates; Form3_1.Updates; Form3_2.Updates; Form3_3.Updates; Form3_4.Updates; Form3_5.Updates; Form3_6.Updates; Form3_7.Updates;Form3_8.Updates;Form3_9.Updates;Form3_10.Updates;Form3_11.Updates; Form3_12.Updates;Form3_13.Updates;Form3_14.Updates;Form3_15.Updates;Form3_16.Updates;Form3_17.Updates;Form3_18.Updates;Form3_19.Updates;Form3_20.Updates;Form3_21.Updates;Form3_22.Updates)

5S Fragen_1 is the name of my SharePoint List and varFormData1 is the item name

1 Answers

You will probably need to write Patch function in a different way:

Patch('5S Fragen_1';varFormData1; {Column1:textbox1.Text, Column2:Textbox2.Text, Column3Number:Value(Textbox3.Text)})

Alternatively, if you are using Forms, you can simply use SubmitForm(FormName1);SubmitForm(Form2); and so on.

Explanation: One way to write a Patch function is:

Patch( DataSource, BaseRecord, ChangeRecord1 [, ChangeRecord2, … ])

Datasource: SharePoint, SQL, Dataverse, etc

BaseRecord: A "record" Type object in Power Apps.

LookUp(DataSource, ID = Value(Textbox1.Text)) 

or

{ID:Value(Textbox1.Text)}

or

First(DataSource)

or

Defaults(DataSource) - this creates a brand new record in your datasource

ChangeRecord1: What you want to change in that BaseRecord object

{
    Title: Box1.Text, //(or maybe ; instead of ,)
    Status: dropdown.Selected.Value
    //....
}
Related