I have a PopUp with only one field >>and a save button >> inside the Save button i have the following formula inside the OnSelect:-
Path(ParentTable,Gallery1.Selected, {Quantity: NewQTY.Text});
now the Patch will update the related record inside the parent table.. so how did the patch know that i want to edit the Quantity of existing record and that i do not want to create a new record with the passed quantity ?
thanks
Hi @johnjohn123
If you pass 2 arguments to the Patch function (like in your example), the patch function merges the two records which effectively results in the edit behaviour that you see.
To create a new record with the passed quantity, you would need to supply Defaults(DataSource) as the second argument to Patch.
There are more details about the merge behaviour in the documentation here:
https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-patch
Because you are not writing Defaults keyword which is necessary to make new records. and also you are specifying specific record. That's how it knows that you want to edit and not create
Hi @johnjohn123
All you have to is from the record your navigating from just onSelect like this code
Editing record onSelect
Set(varItemShipment,ThisItem);
Set(
varFormModeShip,
FormMode.Edit
);Navigate(ShipmentFormScreen);
New record creating button
Set(varItemShipment,ThisItem);
Set(
varFormModeShip,
FormMode.New
);Navigate(ShipmentFormScreen);
On the Form Screen add this The Form DefaultMode
varFormModeShip
Form Item property
varItemShipment
Patch button
Patch(YourListName,varItemShipment,{Quantity: NewQTY.Text});
Please change the names to field screen names
@zmansuri can i know what do you mean by "and also you are specifying specific record. " .. for examplw I could specified a record and add it... Is it this correct? i do not think specifying an item means that it will get edited instead of created..
@timl so can i say that 2 arguments means edit ,,, while 3 arguments means create?
Thanks
To clarify, calling Patch with 2 arguments will never add a record to a data source.
Calling Patch with 3 arguments can either create or update an existing record. If the 2nd argument includes a call to the Defaults function, Patch will create a new record. If the 2nd argument specifies an existing record, Patch will update the record.
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 |
---|---|
186 | |
52 | |
50 | |
34 | |
33 |
User | Count |
---|---|
267 | |
97 | |
84 | |
72 | |
71 |