I think my original problem was using the RowUpdating instead of the RowUpdated event and when the dynamic row changed it was hiding the previously selected value not deleting it. Here is the DAC:
[PXDBString(25, IsUnicode=true)]
[PXUIField(DisplayName="Sub-Status", Required = true)]
[PXDefault()]
[PXDependsOnFields(typeof(BAccount.status))]
[PXStringList(
new string[]
{ "A1", "A2", "A3", "I1", "I2", "I3" },
new string[]
{ "On-Plan", "Off-Plan", "Services Only", "ROR - Same Product", "ROR - New Product", "Out of Business" })]
I ended up having to do a lot of testing in the BusinessAccountMaint_Extension:
private string[] Values2 = { "A1", "A2", "A3" };
private string[] Labels2 = { "On-Plan", "Off-Plan", "Services Only" };
private string[] Values3 = { "I1", "I2", "I3" };
private string[] Labels3 = { "ROR - Same Product", "ROR - New Product", "Out of Business" };
protected void BAccount_Status_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated del)
{
if(del != null)
del(cache, e);
var row = (BAccount)e.Row;
if(row == null) return;
BAccountExt rowExt = PXCache<BAccount>.GetExtension<BAccountExt>(row);
if (row.Status != "I")
PXStringListAttribute.SetList<BAccountExt.usrSubStatus>(cache, row, Values2, Labels2);
else
PXStringListAttribute.SetList<BAccountExt.usrSubStatus>(cache, row, Values3, Labels3 );
if (string.IsNullOrWhiteSpace(rowExt.UsrSubStatus))
{
cache.RaiseExceptionHandling<BAccountExt.usrSubStatus>(row, rowExt.UsrSubStatus,
new PXSetPropertyException("Sub-Status cannot be blank.", PXErrorLevel.Error));
}
}
protected void BAccount_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected del)
{
if (del != null)
del(cache, e);
var row = (BAccount)e.Row;
if (row == null) return;
if (row.Status != "I")
PXStringListAttribute.SetList<BAccountExt.usrSubStatus>(cache, row, Values2, Labels2);
else
PXStringListAttribute.SetList<BAccountExt.usrSubStatus>(cache, row, Values3, Labels3);
}
protected void BAccount_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated del)
{
if (del != null)
del(cache, e);
var row = (BAccount)e.Row;
if (row == null) return;
BAccountExt rowExt = PXCache<BAccount>.GetExtension<BAccountExt>(row);
if (row.Status != "I" && (rowExt.UsrSubStatus == "I1" || rowExt.UsrSubStatus == "I2" || rowExt.UsrSubStatus == "I3"))
cache.RaiseExceptionHandling<BAccountExt.usrSubStatus>(row, rowExt.UsrSubStatus,
new PXSetPropertyException("Sub-Status cannot be blank.", PXErrorLevel.Error));
if (row.Status == "I" && (rowExt.UsrSubStatus == "A1" || rowExt.UsrSubStatus == "A2" || rowExt.UsrSubStatus == "A3"))
cache.RaiseExceptionHandling<BAccountExt.usrSubStatus>(row, rowExt.UsrSubStatus,
new PXSetPropertyException("Sub-Status cannot be blank.", PXErrorLevel.Error));
if (string.IsNullOrWhiteSpace(rowExt.UsrSubStatus))
cache.RaiseExceptionHandling<BAccountExt.usrSubStatus>(row, rowExt.UsrSubStatus,
new PXSetPropertyException("Sub-Status cannot be blank.", PXErrorLevel.Error));
}
Thanks for everyone's help.