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
firstImage

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.

firstImage

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

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

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

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