Hi,
Context:
I am rather new to coding in BPM, but I am trying to select a checkbox every time a row is added to the QuoteMtl table. I know I can easily do this with Set Field in BPM, but when I traced it I found that there are method calls happening in this checkbox. (GetMtlBuyItInfo).
I know the QuoteMtl.BuyIt checkbox is automatically checked for NonStock parts, but we want the checkbox to be checked for stock parts as well.
Goal:
Our associates use the Get Details functionality to get the quote materials. I want the checkboxes to be checked every time a material is added, so I added this code below to Data Directive every time a new record is added to QuoteMtl. This code works if I add the materials manually and individually, but only checks the box and not running GetMtlBuyItInfo during Get Detail.
Any help would be appreciated! Thanks much!
E
// Declare variable hQuoteAsm
Erp.Contracts.QuoteAsmSvcContract hQuoteAsm = null;
// Set hQuoteAsm
hQuoteAsm = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.QuoteAsmSvcContract>(this.Db);
if (hQuoteAsm != null)
{
//get all ttQuoteMtl and put it into ttQuoteMtlResults
var ttQuoteMtlResults = (from ttQuoteMtlRow in ttQuoteMtl where ttQuoteMtlRow.Company == Session.CompanyID && (ttQuoteMtlRow.RowMod == "A") select ttQuoteMtlRow).ToList();
//loop through the list
foreach (var row in ttQuoteMtlResults)
{
// Call the GetByID method and fill in with parameters quotenum, line, assemblyseq
var QuoteAsmDataSet = hQuoteAsm.GetByID(row.QuoteNum, row.QuoteLine, row.AssemblySeq);
//pull out the QuoteMtl from the QuoteAsm dataset
var quoteMtl_Row = (from quoteMtlRow in QuoteAsmDataSet.QuoteMtl
where quoteMtlRow.MtlSeq == row.MtlSeq select quoteMtlRow).FirstOrDefault();
if (quoteMtl_Row != null)
{
//update values
quoteMtl_Row.BuyIt = true;
//quoteMtl_Row.SetRowState(IceRowState.Updated);
quoteMtl_Row.RowMod = "U";
//call GetMtlBuyItInfo to update
hQuoteAsm.GetMtlBuyItInfo(ref QuoteAsmDataSet);
hQuoteAsm.Update(ref QuoteAsmDataSet);
}
}
}