I’m trying to create a code which, like my last few scripts, is meant to keep the values of multiple fields consistent with one another. Today’s two fields are QuoteHed.LongReference_c and OrderHed.LongReference_c, and I’ve written a cluster of FOREACH loops so that when one field is updated, the other field is updated as well. I was able to get this to fire as part of an In-Transaction Data Directive, but that was very unstable. I think that running this AFTER the normal transaction in an Update post-proc should do the trick-- as soon as it starts working. Here’s my BPM:
And here is my code:
foreach (var ttQuoteHedRow in ttQuoteHed)
{
foreach (var OrderDtl_iterator in Db.OrderDtl.Where(OrderDtl_Row => OrderDtl_Row.Company == ttQuoteHedRow.Company && OrderDtl_Row.QuoteNum == ttQuoteHedRow.QuoteNum))
{
foreach (var OrderHed_iterator in Db.OrderHed.Where(OrderHed_Row => OrderHed_Row.Company == OrderDtl_iterator.Company && OrderHed_Row.OrderNum == OrderDtl_iterator.OrderNum))
{
using (System.Transactions.TransactionScope txScope = Erp.ErpContext.CreateDefaultTransactionScope())
{
OrderHed_iterator.LongReference_c = ttQuoteHedRow.LongReference_c;
Db.Validate();
txScope.Complete();
}
}
}
}
And here is my error:
Error CS1061: ‘Erp.Tablesets.QuoteHedRow’ does not contain a definition for ‘LongReference_c’ and no extension method ‘LongReference_c’ accepting a first argument of type ‘Erp.Tablesets.QuoteHedRow’ could be found (are you missing a using directive or an assembly reference?)
In the Data Directive, Epicor had no trouble finding my UD field. Is there a Using or adapter I should call in this context?