I am trying to add a new field to the Sales Order Entry screen. I created a new field as a DAC Extension:
namespace PX.Objects.SO
{
public class SOOrderExt : PXCacheExtension<PX.Objects.SO.SOOrder>
{
#region UsrCustomField
PXString]
PXUIField(DisplayName="Price Class ID", IsReadOnly = true)]
public virtual string UsrPriceClassID { get; set; }
public abstract class usrPriceClassID : PX.Data.BQL.BqlString.Field<usrPriceClassID> { }
#endregion
}
}
I have added the new field to appear on the screen of the Sales Order Form. I want to set the value of this field when the Location is changed.
I have the code to get the value I want to insert into it but I’m not sure how to access the field in the Event Handler under SOOrderEntry.
I tried:
protected void SOOrder_CustomerLocationID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOOrder)e.Row;
if (row == null) return;
// Find the Price Class for the Customer
Location custLoc = PXSelect<Location, Where<Location.locationID, Equal<Required<Location.locationID>>>>.Select(Base, row.CustomerLocationID);
// Set the value of usrPriceClassID to the PriceClassID from Default Location for Customer
row.usrPriceClassID = custLoc.CPriceClassID;
}
It fails to validate as usrPriceClassID doesn’t exist under SOOrder. I think I need to access it via the extension but I’m not sure how.
Thanks for any advice.
Phil