Validate UD field before saving Sales Order Line

I don’t see the table as an option to select when I create the condition:

I think you are being pulled in too many directions.
Here is a summary of what I would do:

  1. For the 3 fields that must be there to SAVE, use Extended Properties and mark those required.
  2. For the other two fields, ince you should not yet have an OrderDtl record, you don’t want the OrderDtl table at this point. The OrderHed table can be filtered by the variable OrderNum. You do not need a RowMod filter because you already saved the Header and the Detail doesn’t yet exist. You would check the remaining 2 fields to ensure they are populated. If not, display an error.
2 Likes

var orderHedRow = (from row in Db.OrderHed where row.Company == Session.CompanyID && row.OrderNum == orderNum select row).FirstOrDefault();
var msgSB = new System.Text.StringBuilder();
var msg = string.Empty;
if(orderHedRow != null)
{
var InitialPoRcvd = orderHedRow.InitialPoRcvd_c;
var InitialPoDate = orderHedRow.InitialPoDate_c;
var CustMatSpec = orderHedRow.CustMatSpec_c;
var DesignUnits = orderHedRow.DesignUnits_c;
var salesRepList = orderHedRow.SalesRepList;
var salesRepCode2 = salesRepList.Split(’~’);

if(InitialPoRcvd == string.Empty)
msgSB.AppendLine(“Initial PO must be entered before Line can be added”);

//2nd condition
if(InitialPoDate == null)
msgSB.AppendLine(“Intitial PO Date must be entered before Line can be added”);

//3rd condition
if(CustMatSpec == string.Empty)
msgSB.AppendLine(“Customer Spec must be entered before Line can be added”);

//4th condition
if(DesignUnits == string.Empty)
msgSB.AppendLine(“Design Units must be entered before line can be added”);

//5th condition
if(salesRepCode2.Length <= 1)
msgSB.AppendLine(“Project Engineer is Mandatory”);

msg = msgSB.ToString();
}
if(msg != string.Empty)
throw new Ice.BLException(msg);

Surendra saved the day!

Spent the afternoon helping me on this, very much appreciated!!!

1 Like