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

Patch Not Overwriting Existing SP List Data

I've got the following in a button. The desire is to have the Patch overwrite the fields displayed on the MemberList and included in the Patch.

 

What the below accomplished was to create a new record, and not simply overwrite the old record.

The item overwritten should be based on the Member's 'UnqID'; the number of which is included in the Patch and in the 'Title' column of the MemberList. 

 

Patch(MemberList,Defaults(MemberList),
{Park:UpdateFormParkDropdown.SelectedText.Park,
NPSReg:UpdateFormNPSRegFld.Text,
DOIReg:Value(UpdateFormDOIRegFld.Text),
UnqID:UpdateFormEngCoParkFld.Text,
SteNmNo:UpdateFormSteNmNoFld.Text,
FrstNm:UpdateFormFirstNmFld.Text,
LstNm:UpdateFormLastNmFld.Text,
MI:UpdateFormMIFld.Text,
FullNm:UpdateFormFullNmFld.Text,
UsrNm:UpdateFormUserNmFld.Text,
MemberEmail:UpdateFormMemberEmailFld.Text,
ECMem:UpdateFormEngCoMemFld.Text,
ActveECMem:UpdateFormActiveECMemberFld.Text,
ProgramHierarchy:UpdateFormProgramHierarchyFld.Text});

 

UpdateContext({UnqIDFldVisible: false});

 

Navigate(SnapShotScrn,ScreenTransition.Cover);

2 ACCEPTED SOLUTIONS

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

When using patch the second parameter is either defaults(data source), when creating a new record, or something like a lookup() to identify an existing record.  Since it uses defaults() the above patch will always create a new record.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Anonymous
Not applicable

My first try; Power Apps didn't like it. What did I do wrong? 

 

3csman_0-1612885646879.png

 

View solution in original post

9 REPLIES 9
Pstork1
Dual Super User
Dual Super User

When using patch the second parameter is either defaults(data source), when creating a new record, or something like a lookup() to identify an existing record.  Since it uses defaults() the above patch will always create a new record.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Would the default data source then be the Gallery or Form in which the updated fields are located? 

The defaults clause says to use the default values in the data source to create a new record. It has nothing to do with the default data source.  The data source is specified in the first parameter.  As I said, to update a record you need to identify which specific record needs to be updated in the second clause.  That's commonly done with a Lookup() 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Yes, sir. Thank you for the clarification.

 

Do you have any suggestions on how the Lookup( ) should be formatted in my case?

 

I'm no expert and am in need of assistance, please.

 

     Patch(MemberList,Defaults(MemberList),
              Lookup(........
                          {Park: UpdateFormParkDropdown.SelectedText.Park,

That depends on what field you have available when doing the patch that uniquely identifies the record you want patched.  Assuming its the UnqID field it would look like this.

Lookup(MemberList, UnqID = UpdateFormEngCoParkFld.Text)

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

My first try; Power Apps didn't like it. What did I do wrong? 

 

3csman_0-1612885646879.png

 

What is the error message when you hover over the formula?  I don't see anything particularly wrong with the syntax.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

You are right, sir. I'm not sure what happens; maybe to much going on.

 

I cut it out and put it back; no errors.

 

Now, let's assume I have a screen another screen with a button for a 'New' Patch of a new record. How would I update the following to achieve that?

 

Patch( NewMemberApprovalList,
Defaults( MemberList, UnqID=NewMemberGalleryUniqueIDFld.Text),
{ UnqID: NewMemberGalleryUniqueIDFld.Text,
SteNmNo: NewMemberGallerySiteNameNoFld.Text,

 

3csman_0-1612891598451.png

 

If by New patch of a new record you mean creating a new record then is should be just like the other patch, but with defaults(Memberlist) as the second parameter.  You are creating a new record so you don't need to identify a specific record, just the data source.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

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.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

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,214)