cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Microsoft Melinda
Microsoft

Record in SQL auto-delete in Edit Mode

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!

2 REPLIES 2
Community Support Team
Community Support Team

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Microsoft Melinda
Microsoft

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.

Helpful resources

Announcements
thirdimage

Power Platform 24

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (5,185)