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);
Solved! Go to Solution.
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.
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.
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()
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)
My first try; Power Apps didn't like it. What did I do wrong?
What is the error message when you hover over the formula? I don't see anything particularly wrong with the syntax.
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,
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.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
180 | |
52 | |
41 | |
38 | |
28 |
User | Count |
---|---|
255 | |
81 | |
71 | |
68 | |
66 |