cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Mammoth
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:

ClearCollect(dbmCollection,'[dbo].[adidas_LineItem_DBM_1]');

ForAll(ddMarket_DBM.SelectedItems,
    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):

 

UpdateContext({showPopup:true});
ClearCollect(colDeletedItems, ShowColumns(Filter(Gallery5.AllItems, Checkbox3.Value = true), "ID"));
RemoveIf(colDeletedItems, ID = colDeletedItems[@ID]);
UpdateContext({showPopup:false});

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

Announcements
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,634)