采购订单行帐户字段不会保留

PO Line Account field won't persist

在采购订单上,我似乎无法保留采购订单行的帐户字段 (ExpenseAcctID)。该值通常出现在 UI 中,当我检查 FieldUpdated、RowUpdated 和 RowPersisted 处理程序中的值时,该字段实际上有一个值。不知何故,它不会持久存在于数据库中。该字段已自定义,如下所示。 .ASPX 中的字段指定为 PXSelector。有什么想法吗?

    [PXMergeAttributes(Method = MergeMethod.Replace)]
    [PXRestrictor(typeof(Where<Account.active, Equal<True>>), PX.Objects.GL.Messages.AccountInactive)]
    [PXRestrictor(typeof(Where<Where<Current<GLSetup.ytdNetIncAccountID>, IsNull,
                        Or<Account.accountID, NotEqual<Current<GLSetup.ytdNetIncAccountID>>>>>), PX.Objects.GL.Messages.YTDNetIncomeSelected)]
    [PXDimensionSelector(AccountAttribute.DimensionName,
        typeof(SearchFor<Account.accountID>
                .In<SelectFrom<Account>
                    .LeftJoin<PMBudget>.On<Account.accountGroupID.IsEqual<PMBudget.accountGroupID>>
                    .Where<
                        Where<POLine.lineType.FromCurrent.IsEqual<POLineType.nonStock>
                            .And<Where<PMBudget.projectID.IsEqual<POLine.projectID.FromCurrent>
                            .And<Where<PMBudget.projectTaskID.IsEqual<POLine.taskID.FromCurrent>
                            .And<Where<PMBudget.costCodeID.IsEqual<POLine.costCodeID.FromCurrent>
                            .And<Where<PMBudget.curyRevisedAmount.IsGreater<Zero>
                            .And<Where<PMBudget.accountGroupID.IsNotNull>
                            >>>>>>>>>
                        .Or<Where<POLine.lineType.FromCurrent.IsNotEqual<POLineType.nonStock>
                            .Or<Where<POLine.projectID.FromCurrent.IsNull
                            .Or<Where<POLine.taskID.FromCurrent.IsNull
                            .Or<Where<POLine.costCodeID.FromCurrent.IsNull
                            >>>>>>>>>>
                    .AggregateTo<GroupBy<Account.accountID>>
                    .OrderBy<Account.accountCD.Asc>>),
            typeof(Account.accountCD),
            new Type[] { typeof(Account.accountCD), typeof(Account.description), typeof(Account.accountGroupID), typeof(PMBudget.curyRevisedAmount),
                typeof(PMBudget.projectID), typeof(PMBudget.projectTaskID), typeof(PMBudget.costCodeID) },
            DescriptionField = typeof(Account.description),
            Filterable = false
            )]
    [PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
    [PXUIField(DisplayName = "Account", Visibility = PXUIVisibility.Visible)]
    protected void POLine_ExpenseAcctID_CacheAttached(PXCache cache)
    {
    }

Acumatica 需要属性 [PXDBInt] 将字段与数据库相关联。 DAC中字段的原始定义是:

#region ExpenseAcctID
public abstract class expenseAcctID : PX.Data.BQL.BqlInt.Field<expenseAcctID> { }
protected Int32? _ExpenseAcctID;
[Account(typeof(POLine.branchID),DisplayName = "Account", Visibility = PXUIVisibility.Visible, Filterable = false, DescriptionField = typeof(Account.description), AvoidControlAccounts = true)]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
public virtual Int32? ExpenseAcctID
{
    get
    {
        return this._ExpenseAcctID;
    }
    set
    {
        this._ExpenseAcctID = value;
    }
}
#endregion

[帐户] 属性包含以下适用于您的属性:

[PXUIField(DisplayName = "Account", Visibility = PXUIVisibility.Visible, FieldClass = DimensionName)]   
[PXDBInt]
[PXInt]
[PXRestrictor(typeof(Where<Account.active, Equal<True>>), Messages.AccountInactive)]
[PXRestrictor(typeof(Where<Where<Current<GLSetup.ytdNetIncAccountID>, IsNull,
    Or<Account.accountID, NotEqual<Current<GLSetup.ytdNetIncAccountID>>>>>), Messages.YTDNetIncomeSelected)]    

通过在 cache_attached 中使用 [PXMergeAttributes(Method = MergeMethod.Replace)],该字段的 DAC 定义中的所有属性都将被删除并仅替换为您定义的内容。

您切换到不包含属性 [PXDBInt] 的 [PXDimensionSelector]。这意味着 Acumatica 无法知道该字段打算绑定到数据库。您仍然可以访问屏幕内的字段,但缓存和数据库之间的交互将跳过该字段。

要解决,只需将 [PXDBInt] 添加到您的 cache_attached 中,如下所示:

[PXMergeAttributes(Method = MergeMethod.Replace)]
[PXDBInt]
[PXRestrictor(typeof(Where<Account.active, Equal<True>>), PX.Objects.GL.Messages.AccountInactive)]
[PXRestrictor(typeof(Where<Where<Current<GLSetup.ytdNetIncAccountID>, IsNull,
                    Or<Account.accountID, NotEqual<Current<GLSetup.ytdNetIncAccountID>>>>>), PX.Objects.GL.Messages.YTDNetIncomeSelected)]
[PXDimensionSelector(AccountAttribute.DimensionName,
    typeof(SearchFor<Account.accountID>
            .In<SelectFrom<Account>
                .LeftJoin<PMBudget>.On<Account.accountGroupID.IsEqual<PMBudget.accountGroupID>>
                .Where<
                    Where<POLine.lineType.FromCurrent.IsEqual<POLineType.nonStock>
                        .And<Where<PMBudget.projectID.IsEqual<POLine.projectID.FromCurrent>
                        .And<Where<PMBudget.projectTaskID.IsEqual<POLine.taskID.FromCurrent>
                        .And<Where<PMBudget.costCodeID.IsEqual<POLine.costCodeID.FromCurrent>
                        .And<Where<PMBudget.curyRevisedAmount.IsGreater<Zero>
                        .And<Where<PMBudget.accountGroupID.IsNotNull>
                        >>>>>>>>>
                    .Or<Where<POLine.lineType.FromCurrent.IsNotEqual<POLineType.nonStock>
                        .Or<Where<POLine.projectID.FromCurrent.IsNull
                        .Or<Where<POLine.taskID.FromCurrent.IsNull
                        .Or<Where<POLine.costCodeID.FromCurrent.IsNull
                        >>>>>>>>>>
                .AggregateTo<GroupBy<Account.accountID>>
                .OrderBy<Account.accountCD.Asc>>),
        typeof(Account.accountCD),
        new Type[] { typeof(Account.accountCD), typeof(Account.description), typeof(Account.accountGroupID), typeof(PMBudget.curyRevisedAmount),
            typeof(PMBudget.projectID), typeof(PMBudget.projectTaskID), typeof(PMBudget.costCodeID) },
        DescriptionField = typeof(Account.description),
        Filterable = false
        )]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Account", Visibility = PXUIVisibility.Visible)]
protected void POLine_ExpenseAcctID_CacheAttached(PXCache cache) { }