You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Acumatica技术咨询:如何从Customer表获取AcctReferenceNbr并拼接至Projects表的External Ref. Nbr

Solution to Fetch Customer's AcctReferenceNbr in ProjectEntry

Let's fix this step by step. The core issue here is that you don't need to rely on the CustomerMaint graph to get the AcctReferenceNbr—you can directly query the related Customer/BAccount record using the CustomerID field from the PMProject row itself.

Correct Code Implementation

Update your ProjectEntry_Extension with this code:

namespace PX.Objects.PM {
    public class ProjectEntry_Extension : PXGraphExtension<ProjectEntry> {
        #region Event Handlers
        protected void PMProject_RowSelected(PXCache cache, PXRowSelectedEventArgs e) {
            PMProject row = (PMProject)e.Row;
            if (row == null || row.CustomerID == null || string.IsNullOrEmpty(row.ContractCD)) 
                return;

            // Fetch the related BAccount (Customer) record using CustomerID
            BAccount customer = PXSelectReadonly<BAccount, 
                                Where<BAccount.bAccountID, Equal<Required<PMProject.customerID>>>>
                                .Select(Base, row.CustomerID);

            if (customer != null && !string.IsNullOrEmpty(customer.AcctReferenceNbr))
            {
                // Combine AcctReferenceNbr with ContractCD (QuoteID)
                row.ExtRefNbr = $"{customer.AcctReferenceNbr}{row.ContractCD}";
            }
            else
            {
                // Fallback if no customer or AcctReferenceNbr exists
                row.ExtRefNbr = row.ContractCD;
            }
        }
        #endregion
    }
}

Key Explanations:

  • Direct Data Query: We use PXSelectReadonly to fetch the BAccount record linked to the project's CustomerID. Since Customer is a subclass of BAccount, AcctReferenceNbr is stored directly on the BAccount table.
  • Null Safety: We added checks for null values (empty row, missing CustomerID, empty ContractCD) to prevent runtime errors.
  • No Cross-Graph Dependency: You don't need to call methods from CustomerMaint—querying the database directly from ProjectEntry is the standard Acumatica approach for accessing related records.

Why Your Previous Attempts Failed:

  1. Cross-Graph Static Method: Calling a static method from CustomerMaint doesn't work because that graph is tied to the Customer screen context, and you don't have a valid BAccount row from the Project screen's event args.
  2. Incorrect Selector Usage: PXSelectorAttribute.Select is meant for interacting with a selector control on the current cache, not for fetching related records from another table.

内容的提问来源于stack exchange,提问作者Andrew Aiello

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 06:17:45