Custom BPM to add QuoteHed_UD field to Sales Order on Opp to Sales Order processing

Did you figure this out? I’m having same issue trying OrderDtl. Only first line gets updated

You might want to add a few additonal lines of code:

  1. a line for the Transaction Scope
  2. add a “lockHint.UpdLock” for record locking
  3. DB.Validate
  4. txScop.Complete

I also moved the read for the order down into the inside of the scop as well as inside the checking for the null quote. No need to read the order if you are not going to modify it.

var quoteNum = Db.OrderDtl.Where(o => o.Company == Session.CompanyID && o.OrderNum == orderNum).Select(x => x.QuoteNum).FirstOrDefault();
if (quoteNum != null) {
    var quote = Db.QuoteHed.Where(q => q.Company == Session.CompanyID && q.QuoteNum == quoteNum).Select(x => new { x.DecorType_c, x.BldgType_c }).FirstOrDefault();
    if (quote != null) {
        //UD fields to copy to SO from Quote BldgType

        using(var txScope = IceContext.CreateDefaultTransactionScope()) {
            var order = Db.OrderHed.With(LockHint.UpdLock).Where(o => o.Company == Session.CompanyID && o.OrderNum == orderNum).FirstOrDefault();
            order.DecorType_c = quote.DecorType_c;
            order.BldgType_c = quote.BldgType_c;
            Db.Validate();
            txScope.Complete();
        }
    }
}
1 Like

Thanks @timshuwy

What are the advantages of using there two points?

This makes sure that you have the record available to update and it will reduce errors.

Thank you Sir,

Learning never stops, … I learned by copying our implementer’s coding… and mistakes

1 Like

What mean “o” “q” and “x” where are the variables???