Hello! I'm an IT project manager working with a Power Platform team on an app used in hospitals.
The app is connected to a posgresql database via the premium posgresql connector and the data moves through a data gateway. Both the server for the data gateway and the database are inside our network.
The app features a list of hospitalized people. Some data comes from other databases that we have and available for read only (name, location, age, etc).
The other fields are either just comments or dropdown lists for the user to interact with. The fields are saved automatically when you click out of the box.
Our issue is with those comment fields that use the Patch() function.
In some cases, the field edited simply doesn't save. I would say this happens about 1 or 2% of the time, doesn't matter which user or which field or what is written in the comment.
We've been trying to diagnose and find where exactly the issue is coming from.
We investigated logs from posgreSQL and the datagateway and there doesn't seem to be anything wrong with them. We couldn't find the erased entries in the datagateway logs, which makes us think that they don't even get there to begin with. We also checked for any resource issues on our servers and they're all great!
We've monitored sessions of active users during a peak usage time and powerapps doesn't return any errors for this. Every Patch() has an iferror(), but this particular issue doesn't return an error.
We've copiloted this and our best guess is that there are "silent errors" on the failed Patch functions. I read that it is possible that if there are many updates at the same time, that powerapps might just forget about some and they never go through.
To try and fix that, we've put the Patches in a collection and we send them one by one every 500ms. This didn't fix the problem.
We read that automatic saving is probably not the best way to use PowerApps. Maybe a form with a save button would be best, it's just not what the clients wanted. Before we change everything though, we want to make sure there isn't anything else we can check or tests we can do or something we can change in the code to try and fix the problem.
Here's a few lines of code to show how the Patches are done (don't mind the French) :
Patch('public.SejoursInfosCompl';LookUp('public.SejoursInfosCompl'; SejourId = varSejourId);
{
CommentaireReadaptation: varEnvoi.ChampModifieValeur;
DateModification: Now();
EmailUtilisateur: varUserEmail;
PatientId: varEnvoi.PatientId;
ContenuChampModifie: varEnvoi.JournalNouvelleValeur
//varEnvoi.ChampModifie & "~" & varEnvoi.JournalNouvelleValeur
} );
où varEnvoi = UpdateContext({ varEnvoi: First(ColFileAttente); varSejourId:First(ColFileAttente).IDSejour });;
;;If(!IsEmpty(Errors('public.SejoursInfosCompl'));
Notify("Échec : " & First(Errors('public.SejoursInfosCompl')).Message; NotificationType.Error)
;Remove(ColFileAttente; varEnvoi)
)
Any help or ideas would be greatly appreciated!
Thank you :)