I added a check box (Line is on hold) on the line detail page. I check to see if the customer or order is on credit hold and if credit override is set or not.
This all works and checks the check box if it’s on credit hold and unchecks it if it’s not. My problem is it is not checking or unchecking the box unless you change something on the sales order and select save.
Currently I have it on the OrderDtl - In-Transaction. I’ve tried moving it to method directives Erp.BO.SalesOrder.Update reprocessing neither works. Any suggestions?
var c = ttOrderDtl.FirstOrDefault(x => x.RowMod == "U");
if (c != null)
{
var y = Db.OrderHed.FirstOrDefault(x => x.Company == c.Company && x.OrderNum == c.OrderNum);
// Added null check for y and y.PONum (though PONum check is usually optional unless business logic requires it)
if (y != null)
{
var b = Db.Customer.FirstOrDefault(s => s.Company == y.Company && s.CustNum == y.CustNum);
if (b != null)
{
// If Customer is on Hold OR Order is on Hold
if (b.CreditHold || y.OrderHeld)
{
// If there is an override, release the line hold, otherwise set it
bool shouldHold = !y.CreditOverride;
c.SetUDField<bool>("LineHold_c", shouldHold);
}
}
}
}```