I am trying to set a custom field on a brand new BAccount object created via the action ConvertToBAccount() in the Contact BLC. I've tried quite a few different things including overriding the action and trying to set the value on the object after the action is complete and navigates to the BAccount BLC. I found that I can't set the value on the override because there is no record in the database until the user manually saves, and when I try to set the value after the action, it sets the field, but does not show the new value on the screen when the BAccount BLC is done loading.
How can I set an extension field for a new BAccount created via the ConvertToBAccount() action on the Contacts BLC?
DAC Extension:
public class BAccountExt : PXCacheExtension<PX.Objects.CR.BAccount>
{
#region UsrHomeCampus
[PXDBInt]
[PXUIField(DisplayName="Home Campus")]
[PXSelector(typeof(Search<PX.Objects.GL.Branch.branchID>),
typeof(PX.Objects.GL.Branch.branchCD),
SubstituteKey = typeof(PX.Objects.GL.Branch.branchCD))]
public virtual int? UsrHomeCampus { get; set; }
public abstract class usrHomeCampus : IBqlField { }
#endregion
}
BLC Code:
public class BusinessAccountMaint_Extension : PXGraphExtension<BusinessAccountMaint>
{
#region Event Handlers
protected void Contact_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
Contact row = (Contact)e.Row;
if (row.ContactID > 0 && Base.CurrentBAccount.Current.BAccountID < 0)
{
Base.CurrentBAccount.Current.GetExtension<BAccountExt>().UsrHomeCampus = row.GetExtension<ContactExt>().UsrHomeCampus;
//Save record in database
Base.Actions.PressSave();
//Cause page refresh
Base.Actions.PressCancel();
}
}
#endregion
}