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 / Record in SQL auto-del...
Power Apps
Unanswered

Record in SQL auto-delete in Edit Mode

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a Power App that is connected to several SQL Databases for Lookups but also saves in a separate Database/table. 

 

For some reason it appears when the end users edit a record, they can save it and it then disappears/deletes from the database. The only way I have noticed that is that the ID skips. For example Record ID 364,365,366 then it goes to 368 making me assume we are losing rows. 

 

I use the current formulas: 

 

Display Screen

Edit Icon on Select: EditForm(EditForm);Navigate(EditDeskJournal,ScreenTransition.None)

 

EditScreen

Items are set to= Gallery1.Selected

  • Example
    • Combo Datacard Items: SortByColumns(Filter(Lookup_Database',Filter1=Value),Column,Ascending)
    • DefaultSelectedItems= If(EditForm.Mode=FormMode.Edit,Filter(Lookup_Database,Column=Gallery1.Selected.Column)).Column
    • DataCard Update=Combobox.Selected.Column

Submit Icon (I have tried a couple of things)

  1. SubmitForm(Form1)
  2. If(EditForm.Mode=FormMode.Edit,Patch(Main_Database,Gallery1.Selected,{Column Name: Columnvalue....},SubmitForm(Form1)

I am not sure if there is something wrong with the formula of it not saving or if I am missing another step. Whenever I do a test I have no issues with the data being removed/deleted. 

 

Thanks in advance!

Categories:
I have the same question (0)
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Melinda ,

    Have you put some Remove formula within the OnSuccess property of the Edit form in your app?

     

    Based on the formula you provided, I could not find any formula which is used to remove/delete record from your table. Please check if you have added a Remove formula within the OnSuccess property of the Edit form, when your submit your form data successfully, the OnSuccess property of the Edit form would be fired.

     

    In addition, please consider take a try with the following workaround:

    Set the Items property of the ComboBox to following:

    SortByColumns(Filter(Lookup_Database',Filter1=Value),Column,Ascending)

    Set the DefaultSelectedItems property of the ComboBox to following:

    If(
     EditForm.Mode = FormMode.Edit,
     Filter(Lookup_Database, Column = Gallery1.Selected.Column).Column
    )

    or

    {
     Column: Gallery1.Selected.Column
    }

     

    Set the OnSelect property of the "Submit" button to following:

    If(
     EditForm.Mode = FormMode.Edit,
     Patch(
     Main_Database,
     Gallery1.Selected,
     EditForm.Updates
     ),
     Patch(
     Main_Database,
     Defaults(Main_Database),
     EditForm.Updates
     )
    );
    ResetForm(EditForm);
    Back()

     

    In addition, please also check if you set up a ms flow to delete the record from your table when a record is modified.

     

    If the issue still exists, please consider re-generate a new app based on your table data source, then configure the combobox data cards in your Edit form, then try the app again, check if the issue is solved.

     

    Best regards,

  • Melinda Profile Picture
    Microsoft Employee on at

    @v-xida-msftThank you for getting back to me. I checked on the OnSuccess, I have no remove formula there. I added the EditForm.Updates but I am still losing data. I am missing 4 out of 125 entries which is better than before. Could there be another reason why SQL may "skip" an ID? Could there be an issue with multiple people submitting an entry at the same time? Thank you.

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 326 Most Valuable Professional

#2
11manish Profile Picture

11manish 168

#3
sannavajjala87 Profile Picture

sannavajjala87 75 Super User 2026 Season 1

Last 30 days Overall leaderboard