0
votes

Am trying to set a default customer for CS but am am getting an error "RevisionID' cannot be empty" please assist

protected void SOOrder_CustomerID_FieldUpdating(PXCache cache, PXFieldUpdatingEventArgs e)
{
  SOOrder row = (SOOrder)e.Row;

  if(row == null) return;

   if (row.OrderType == "CS" || row.OrderType == "SS")
       {
           row.CustomerID = 7211;  

        } 

   else
       {
           row.CustomerID = null;  
        } 

}
1
I think you need to have this code in OrderType_FieldUpdated to then trigger the default for the Customer? right now if you are trying to change the value of customerid when the customerid field is updated which will only occur if someone is entering a customer. - Brendan

1 Answers

1
votes

In your specific case FieldDefaulting event must be used instead of FieldUpdating to generate default value for the Customer ID field. According to the API Reference, in FieldDefaulting event handlers the new value must be assigned to the NewValue property of PXFieldDefaultingEventArgs and never directly to the DAC field:

protected void SOOrder_CustomerID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
{
    SOOrder row = (SOOrder)e.Row;
    if(row == null) return;

    if (row.OrderType == "CS" || row.OrderType == "SS")
    {
        e.NewValue = 7211;  
    } 
}