I have a custom maintenance screen that has a form and a grid. The form is attached to one table (ICSPricingHeader table). When I insert a record in the grid, I want to default the PriceClassID field in the grid (ICSPricingINItemClass) to default to the value in the header table. In the screen below, I am showng the PriceClassID on the grid just so I can verify the value in the field is populated.

When I click the plus sign, the PriceClassID is not being filled in. If I try to save the record, I get a “you didn’t provide a priceclassid” error.
In my child table DAC, I have the following code that I think should be putting the Price Class ID from the top of the form into the table (cache).
#region PriceClassID
[PXDBString(10, IsUnicode = true, IsKey = true)]
[PXDefault(typeof(ICSPricingHeader.priceClassID.FromCurrent))]
public virtual string PriceClassID { get; set; }
public abstract class priceClassID : PX.Data.BQL.BqlString.Field<priceClassID> { }
#endregion
The PXDefault should be pulling the current value from the ICSPricingHeader current value, but it is not.
To make sure that there is a current value in the Header table, I put code in the RowInserting handler of the child table. This code does populate the child table and I can save the record.
protected void ICSPricingINItemClass_RowInserting(PXCache cache, PXRowInsertingEventArgs e)
{
var row = (ICSPricingINItemClass)e.Row;
if(MasterView.Current != null)
{
row.PriceClassID = MasterView.Current.PriceClassID;
}
}
It seems like I should be able to default the field value of a new record in the child table from the PXDefault and NOT have to do it in an event handler.
I know that the Current of the Header table has a value as the RowInserting hander is able to set the value.
What am I doing wrong?