GetNewQuoteDtl vs AddQuoteDtlRow

Has anyone had success creating multiple quote/order detail lines in the QuoteDtl dataset? I’m trying to create multiple QuoteDtl lines on the quote via code, but it only seems to add one even when calling the GetNewQuoteDtl multiple times.

Here’s what I’ve tried:

                Erp.Proxy.BO.QuoteImpl quote = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.QuoteImpl>(session, Erp.Proxy.BO.QuoteImpl.UriPath);

                Erp.BO.QuoteDataSet quoteDataset = quote.GetByID(30388);

                for (int n = 1; n <= 4; n++)
                {
                    quote.GetNewQuoteDtl(quoteDataset, 30388);

                    DataRow quoteDtl_xRow = quoteDataset.Tables["QuoteDtl"].Select().LastOrDefault();

                    quoteDtl_xRow["PartNum"] = "Part " + n;
                    quoteDtl_xRow["SellingExpectedQty"] = n;
                    quoteDtl_xRow["OrderQty"] = n;
                    quoteDtl_xRow["LineDesc"] = "Test Multi " + n;
                    quoteDtl_xRow["ProdCode"] = "AGuide";
                }

                quote.Update(quoteDataset);

As I step through my test code, the QuoteDtl dataset count remains at 1 even as iteration count is at 4 (the QuoteDtl count should be equal to the iteration count).

image

I also noticed the AddQuoteDtlRow method which appears to create detail rows as well. However, I’ve tried calling the method (as shown below) with no luck as well. It gives me the error “This row already belongs to this table.”

quoteDataset.QuoteDtl.AddQuoteDtlRow((Erp.BO.QuoteDataSet.QuoteDtlRow)quoteDtl_xRow);

I’m basically trying to determine if GetNewQuoteDtl is the best method to use, or if I should consider AddQuoteDtlRow for creating multiple detail lines/rows (and how can I get the dataset to actually add multiple QuoteDtl lines). I haven’t found much info on here in regards to AddQuoteDtlRow.

Thanks for the help!

~ Josh

You likely want GetNewQuoteDtl. You will see in a trace that this is likely what the system does.
Try putting the Update inside the loop.
Also, you may want to select the row with RowMod=A instead of LastOrDefault.

Thanks for your input Jason. I’ve set the RowMod to “A”, but still just creates the one line.

Since the GetNewQuoteDtl method is a void, how else would I get the row that was created?

You will want to SELECT the row where RodMod=A

That gets the row just as the LastOrDefault does. However, I’m trying to create new entries in the dataset which don’t appear to happen each time I call GetNewQuoteDtl. I would have thought it would, but it will only add one record no matter how many times I call the method.

I currently have code that does call the update inside a loop. However, I’m trying to create a “batch” add process that would add multiple detail records and then save them.