Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Adding and Removing Multiple Records Error

Hi All,


I'm adding multiple concatenations of comboboxes/dropdowns to a textbox and inserting it into an SQL database, depending on the number of options the user selects in a combobox. For example, if they select three markets, then three rows will be added into the table, four markets, then four rows, etc. The concatenation is exactly the same on each row, except for the country code.


When a button is press, it looks to see if it exists in the table already:


    ForAll(Filter(Gallery4.AllItems, Label5.Text = Code),

    If(LineItemErrorDBM.Text <> "ERROR",
    If(LookUp(dbmCollection, InsertionOrderDBM = Label2.Text And LineItemDBM = 
        Concatenate( ... //combobox values )

If it doesn't, will Patch() the new values in. If it does exists, an error notification pops up saying the value already exists. Because the SQL database has a lot of records that will constently have values being added to it, I have done a ClearCollect() function that creates a collection as I was getting a delegation warning.


When I initially press the button, I have no issues. I also have a Remove button that will remove all the selected values in the gallery (where all the text values are stored):


ClearCollect(colDeletedItems, ShowColumns(Filter(Gallery5.AllItems, Checkbox3.Value = true), "ID"));
RemoveIf(colDeletedItems, ID = colDeletedItems[@ID]);

Again, that button works fine, even with a fair amount of markets. Where the issue lies is adding these text values back in. 


Say I add in 14 markets the first time, 14 rows get added to the SQL table so prefect. If the user removes all these values and then tries to re-add them, they will only add 12. Even though there are no repeat values and it was working fine the first time round. If I repeat this process, it will only add the rows minus one or two each time. 


Am I missing something? Has anyone experienced this sort of issue before?


Any guidance would be greatly appreciated.


Thank you.

Helpful resources


New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (3,906)