When I try to save changes on order lines or create an order from a quote, I get this error pointing to a BPM:
BPM runtime caught an unexpected exception of ‘NullReferenceException’ type.
See more info in the Inner Exception section of Exception Details.
Exception caught in: Epicor.ServiceModel
Inner Exception
Object reference not set to an instance of an object.
Here’s my code:
var ttOrder = (from tt in ttOrderHed select tt).FirstOrDefault();
if (ttOrder.CustNum !=null)
{
int Cust = ttOrder.CustNum;
var ttCst = Db.Customer.Where(ttC=>ttC.CustNum == Cust).FirstOrDefault();
if (ttOrder.UserChar1 != ttCst.CustID)
{
ttOrder.UserChar1 = ttCst.CustID.ToString();
}
}
It works when modifying existing sales orders, but not with new orders it seems. Anyone see what’s wrong with it?