Hello,
imagen a powerapp with multiple input tab and fields and a save button. Behind this button i have a patch command which update multiple tables in dataverse. Combined with the Patch action i have a error handling which prevent a bad data quality. Fine so far.
But how could i bring a kind of transaction or Complition Handling in place to get sure everthing is saved successfully.
The experience in the past wasn't that good so we face some update issues because the patch process from time to time do not update all tables ....
One option we discussed was a powerautomate but this couldn't be the solution. Is there any kind of "inbuild" solution / mechanisms to handle this ?
Best regards MD
Solved! Go to Solution.
In this case there would be nothing to do since you are creating a new record. With a new record there is nothing to back out.
But let's say you are patching two tables with edits. One of the patches fails. Then the record for the patch that succeeded will need to be re-patched with the original values to roll back the patches. Nothing will need to be done with the one that failed because it failed. Restoring the original values will require temporarily storing the previous values somewhere so they can be put back. This all becomes very complicated in Power Apps and it gets worse with every additional patch.
Because Power Automate is procedural it is still complex but a bit more manageable.
There is no built in support for transactions. So your only real choice is to save the existing data for the record being patched from each of the tables and re-apply it if any of the updates fail. Since Power Apps is a declarative system this is more difficult to do in Power Apps than it would be in Power Automate where actions are procedural. But it should be possible in either system. Each Patch() statement will return a boolean if it succeeds or fails. you need to check that all Patches returned true. If not you need to Patch the original records back in place.
Thx for your response how i could check the return value of each patch statement?
Is it recommended to have only once for all tables or multiple, one for each table?
Is there any architectural option to handle this in a better way than with patch and the error handling of it?
You have to patch each table separately. But the patch() will return a value signifying whether it was successful or not. You can capture that value in a variable.
Set(PatchResult, Patch(.....
PatchResult will be true if the Patch was successful and false if it wasn't.
As I said, Power Automate is procedural and has some capability to do error checking. But other than that there isn't really a lot you can do.
How i could handle this with this example.
Check the patchresult and how could be the reaction if the result ist NOK
Patch(YPC_Head;Defaults(YPC_Head);{IDypc:myNewIDypc; VBELN:myNewVBELN; POSNR:myNewPOSNR; KMAT_P22:myKMATP22; KMAT:myKMAT; ERDAT:Now(); YPCversion: myYPCversion; KWMENG:myKWMENG; NETWR:myNETWR; VA00:myVA00; EK02:myEK02; SKA:mySKA; SWSK:mySWSK; ConfigText: myConfigTextHead; UserID:myUser; Information:myInfo; StatusYPC:myIDypcStatus; StatusID:myStatusID; IDcopy:myIDcopy});
Set(myNewSDstatus;"Duplicate")
Set(patcherrormPatch(YPC_Head;Defaults(YPC_Head);{IDypc:myNewIDypc; VBELN:myNewVBELN; POSNR:myNewPOSNR; KMAT_P22:myKMATP22; KMAT:myKMAT; ERDAT:Now(); YPCversion: myYPCversion; KWMENG:myKWMENG; NETWR:myNETWR; VA00:myVA00; EK02:myEK02; SKA:mySKA; SWSK:mySWSK; ConfigText: myConfigTextHead; UserID:myUser; Information:myInfo; StatusYPC:myIDypcStatus; StatusID:myStatusID; IDcopy:myIDcopy}));
Then have an error label with visible = to
If(patcherror,true,false)
But that is just trying to create a new record in one table. There would be a lot more involved if you want to also back out the entries in other tables.
Hi,
thx for your response, but what could be the action if the return is false?
What you mean with "back out the entries in other tables" ? Do you talking about deleting entries?
What is the required action in this case?
Thx
In this case there would be nothing to do since you are creating a new record. With a new record there is nothing to back out.
But let's say you are patching two tables with edits. One of the patches fails. Then the record for the patch that succeeded will need to be re-patched with the original values to roll back the patches. Nothing will need to be done with the one that failed because it failed. Restoring the original values will require temporarily storing the previous values somewhere so they can be put back. This all becomes very complicated in Power Apps and it gets worse with every additional patch.
Because Power Automate is procedural it is still complex but a bit more manageable.
User | Count |
---|---|
252 | |
107 | |
90 | |
51 | |
44 |