Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

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


Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.


Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Power Platform World Tour

Coming to a city near you


PowerApps Community User Group Member Badge

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


Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 4 members 4,701 guests
Please welcome our newest community members: