I am setting the Default branch on the SOOrder using the Employees Default Branch:
using PX.Objects.IN.Matrix.Interfaces;
using System;
using PX.Common;
using PX.Data;
using PX.Objects.CS;
using PX.Objects.EP;
namespace PX.Objects.SO
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
#region Event Handlers
protected void SOLine_BranchID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
{
try
{
var row = (SOLine)e.Row;
if (row == null) return;
EPEmployee CurEPEmployee = PXSelect<
EPEmployee,
Where<EPEmployee.userID, Equal<Required<AccessInfo.userID>>>>
.Select(Base, Base.Accessinfo.UserID);
BranchMaint.BranchBAccount CurBranchBAccount = PXSelect<
BranchMaint.BranchBAccount,
Where<BranchMaint.BranchBAccount.bAccountID,Equal<Required<EPEmployee.parentBAccountID>>>>
.Select(Base,CurEPEmployee.ParentBAccountID);
e.NewValue = CurBranchBAccount.BranchBranchCD;
}
catch (Exception ex)
{
PXTrace.WriteError(ex);
}
}
#endregion
When I use the same code to set the branch on Purchase Orders the BranchMaint.BranchBAccount is always null as if the POReceiptEntry_Extension doesn't have access to it?
using PX.Data;
using PX.Objects.EP;
using static PX.Objects.CS.BranchMaint;
using System;
namespace PX.Objects.PO
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class POReceiptEntry_Extension : PXGraphExtension<POReceiptEntry>
{
#region Event Handlers
protected void POReceiptLine_BranchID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
{
try
{
var row = (POReceiptLine)e.Row;
if (row == null) return;
EPEmployee CurEPEmployee = PXSelect<
EPEmployee,
Where<EPEmployee.userID, Equal<Required<AccessInfo.userID>>>>
.Select(Base, Base.Accessinfo.UserID);
BranchBAccount CurBranchBAccount = PXSelect<
BranchBAccount,
Where<BranchBAccount.bAccountID, Equal<Required<EPEmployee.parentBAccountID>>>>
.Select(Base, CurEPEmployee.ParentBAccountID);
e.NewValue = CurBranchBAccount.BranchBranchCD;
}
catch (Exception ex)
{
PXTrace.WriteError(ex);
}
}
#endregion
}
}
Is there any way for me to access BranchMaint.BranchBAccount from POReceiptEntry_Extension