cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Re: How to update a record with Patch?

I have not solved the problem due to I chose not to use the FormMode as you suggested. I am still struggling with how to instruct Patch to pick up the record and show it on the next screen. Only thing I accomplished so far is to reset the current values to defaults. Maybe I should use Collections and put that data in a variable and then populate the next screen with the values?

Highlighted
Community Support
Community Support

Re: How to update a record with Patch?

Hi @DG1000 ,

Do you not use Edit form to collect data?

 

I think you have some misunderstanding with the Patch function in PowerApps. The Patch function is used to create a new record or update an existing record in a data source, which is not used to retrieve a record from a data source.

 

If you just want to populate the separated text Input box when you click ">" icon in your Gallery, you could consider save the selected item in your Gallery into a variable, then reference the column value from this variable and set as default value within this separated TextInput boxes.

Please set the OnSelect property of the ">" icon in Gallery to following:

Set(CurrentItem, ThisItem);
Navigate(NextScreen)

 

Within your Next screen, please set the Default property of the Text Input boxes to following:

CurrentItem.Column1
CurrentItem.Column2

.....

 

Then add formula to clear the CurrentItem variable after you execute your Patch formula:

Patch(                               // edit existing record
          '[dbo].[tblTicketsIT]',
          LookUp('[dbo].[tblTicketsIT]', PrimaryColumn = Gallery1.Selected.PrimaryColumn),
          {
            CREATOR: txtCREATOR.Text, 
            PRIORITY: cmbPRIORITY.Selected.Value, 
            DEPARTMENT: txtDEPARTMENT.Text, 
            LOCATION: txtLOCATION.Text ,
            ISSUE: txtISSUE.Text, 
            IMAGE: Camera2.Photo
          }
);
Set(CurrentItem, Blank())  // Add this formula

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper I
Helper I

Re: How to update a record with Patch?

Sorry for the late reply,

You are correct about my assumption about what the patch does as in I am trying to use Patch to retrieve a record.

I tried your approach with some odd results where the data "hangs" there even though I am trying to create a new record, seems like after using Patch to create a new record the data is somehow saved in the memory and next time I try to create a new record the data is still there...😕 I even tried to create a new app from scratch but the result was the same, "ghost" data started to show up even when creating a new record.

 

Thank you for your patience and for helping me with this issue.

Highlighted
Community Support
Community Support

Re: How to update a record with Patch?

Hi @DG1000 ,

Actually, after you execute your Patch function, these Text Input Boes would not be reset automatically (Which is not different from these controls within a Edit form).

 

If you use Patch function to submit your data, please add Reset() function to reset these Text Input controls. Modify your formula as below:

Patch(                               // edit existing record
          '[dbo].[tblTicketsIT]',
          LookUp('[dbo].[tblTicketsIT]', PrimaryColumn = Gallery1.Selected.PrimaryColumn),
          {
            CREATOR: txtCREATOR.Text, 
            PRIORITY: cmbPRIORITY.Selected.Value, 
            DEPARTMENT: txtDEPARTMENT.Text, 
            LOCATION: txtLOCATION.Text ,
            ISSUE: txtISSUE.Text, 
            IMAGE: Camera2.Photo
          }
);
Set(CurrentItem, Blank())  // Add this formula
Reset(TextInput1);Reset(TextInput2);Reset(TextInput3);....   // add Reset function to reset these separated controls

 

Best regards,

Community Support Team _ Kris Dai
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

Highlighted
Helper I
Helper I

Re: How to update a record with Patch?

That didn't work until I applied the same formula even when creating new records like this:

Navigate(NextScreen);
Set(CurrentItem, Blank());
Reset(txtCREATOR);Reset(cmbPRIORITY);Reset(txtDEPARTMENT);Reset(txtLOCATION);Reset(txtISSUE);

 Now, it works flawlessly. Thank you 😊

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,325)