So, I’ve leaned that I need to sharpen my LINQ skills but, until then, can someone help me find out what’s wrong with my code? It works swimmingly when the source quote has all lines in sequence, but if the source quote has a deleted line it bombs.
My end goal is to duplicate the quantity fields from an existing quote when clicking “Actions” -> “Quote” -> “Duplicate Quote”.
So far I have created a Post-Processing BPM that sets a BPM Data Field, callContextBpmData.Number02, to Convert.ToDecimal(sourceLines.Split(’~’)) and then runs the following custom code:
foreach (var tt in ttQuoteDtl)
for(int i = 0; i < callContextBpmData.Number02; i++ )
var dbqt = Db.QuoteDtl.Where(p => p.Company == tt.Company && p.QuoteNum == tt.QuoteNum && p.QuoteLine == i+1).FirstOrDefault();
dbqt.OrderQty = Db.QuoteDtl.Where(m => m.Company == tt.Company && m.QuoteNum == sourceQuote && m.QuoteLine == i+1).Select(p => p.OrderQty).FirstOrDefault();
dbqt.SellingExpectedQty = Db.QuoteDtl.Where(m => m.Company == tt.Company && m.QuoteNum == sourceQuote && m.QuoteLine == i+1).Select(p => p.SellingExpectedQty).FirstOrDefault();
Again, if the original quote has all of its lines in order my code works, but when Customer Service deletes a line and clicks “Duplicate Quote” the application throws an exception.