web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Lost of data when usin...
Power Apps
Answered

Lost of data when using patches.

(0) ShareShare
ReportReport
Posted on by 2
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 :)
I have the same question (0)
  • stampcoin Profile Picture
    5,171 Super User 2026 Season 1 on at
    Have you tried trace() function to trace the data/event in monitor or test studio ?
    Do you use Application insights ?
     
    Another thought I think that use collection for your patch.
     

    Enjoy Power Platform and have a great day 🚀 |  My LinkedIn

    If the answer helps, please consider 👍, Thanks.

     
     
  • Verified answer
    WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    Based on your statement that the issue only occurs only 1-2% of the time, I suspect the issue may be exactly what you have identified as not the best way to use Power Apps - you are correct here.
     
    I assume you are using the OnChange property of the text control - this trigger requires a specific set of events and a number of things can possibly result in the desired action not being implemented (the Patch simply does not run) - examples may be the user changing records directly after or scrolling the gallery. You really need a button/icon - something the user presses which positively triggers the action.
     
    This is probably not useful to you, but I have a blog on an editable gallery model showing the extent I go to ensure the user saves the correct record.
     
    Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn  
  • stum Profile Picture
    144 on at
     
    I would try this to see if you have silent cancellation.
    Set(
        varPatchResult,
        Patch('public.SejoursInfosCompl';LookUp('public.SejoursInfosCompl'; SejourId = varSejourId);
             {
               CommentaireReadaptation: varEnvoi.ChampModifieValeur;
               DateModification: Now();
               EmailUtilisateur: varUserEmail;
               PatientId: varEnvoi.PatientId;
               ContenuChampModifie: varEnvoi.JournalNouvelleValeur
             } )
    );
    
    If(
        IsBlank(varPatchResult),
        Notify("Patch returned blank (cancelled)", NotificationType.Error)
    )
    so if you see the notification then you have a silent cancellation. I know you mentioned that your clients don't want a save button but in my opinion it would be better to create one to solve this issue.
     
    Hope this helps!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard