Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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!

  • Melinda Profile Picture
    Microsoft Employee on at
    Re: Record in SQL auto-delete in Edit Mode

    @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.

  • v-xida-msft Profile Picture
    on at
    Re: Record in SQL auto-delete in Edit Mode

    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,

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 110 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 81

#3
stampcoin Profile Picture

stampcoin 54

Overall leaderboard