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

Acumatica案例模块附加网格无法显示全部关联PXSelect数据

问题描述

已在Acumatica的案例(Cases)屏幕中通过代码条件创建名为“CAM Info”的新网格,但当前PXSelect命令仅显示Relations网格的第一行数据。需求是基于CRRelation.targetNoteID拉取所有关联的ARRegister数据,并在“CAM Info”网格中全部显示,询问如何修改代码实现该功能。

原代码

using System.Collections.Specialized;
using System.Linq;
using PX.Common;
using PX.Data;
using System.Collections;
using PX.Data.EP;
using PX.Objects.AR;
using PX.Objects.CT;
using PX.Objects.CR.Workflows;
using PX.Objects.GL;
using PX.Objects.EP;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.SM;
using PX.TM;
using PX.Objects;
using PX.Objects.CR;
using System.Net.Http;
using System.Collections.Generic;
using System.Collections;

namespace PX.Objects.CR
{
  public class CRCaseMaint_Extension : PXGraphExtension<CRCaseMaint>
  {     
    #region Event Handlers
        protected virtual void CRCase_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
          {
            InvokeBaseHandler?.Invoke(cache, e);
            var row = (CRCase)e.Row;
            if (row != null)
              {
                if (row.CaseClassID == "CAM")
                  {
                    PXUIFieldAttribute.SetVisible<Objects.CR.CRCaseExt.usrRMAReason>(cache, row, false);
                    PXUIFieldAttribute.SetVisible<Objects.CR.CRCaseExt.usrSupportCategory >(cache, row, false);
                    PXUIFieldAttribute.SetVisible<Objects.CR.CRCaseExt.usrContractDesc>(cache, row, false);
                    PXUIFieldAttribute.SetVisible<Objects.CR.CRCaseExt.usrCaseStage>(cache, row, false);
                    PXUIFieldAttribute.SetVisible<Objects.CR.CRCaseExt.usrIGAHEquipmentID>(cache, row, false);                 
                  }
              } 
          } 
    #endregion
        
    // Following view delaration populates the ARRegister info; but only one line            
    #region Selects  
       public PXSelect<ARRegister, Where<ARRegister.noteID, Equal<CurrentValue<CRRelation.targetNoteID>>>> CAMRelationsView;
    #endregion
  }
}
解决方案

当前代码仅返回单行数据的核心原因是CurrentValue<CRRelation.targetNoteID>仅会获取当前选中的单条CRRelation记录的targetNoteID,因此只能关联到对应的单行ARRegister。要获取当前案例所有关联的ARRegister,需要通过表关联筛选出所有符合条件的数据。

修改Selects区域的CAMRelationsView定义,使用PXSelectJoin关联ARRegister与CRRelation表,筛选当前案例下的所有关联记录:

#region Selects  
public PXSelectJoin<ARRegister,
    InnerJoin<CRRelation, On<CRRelation.targetNoteID, Equal<ARRegister.noteID>>>,
    Where<CRRelation.refNoteID, Equal<Current<CRCase.noteID>>>> CAMRelationsView;
#endregion

修改说明

  1. 表关联逻辑:通过InnerJoin将ARRegister与CRRelation绑定,关联条件为CRRelation.targetNoteID == ARRegister.noteID,确保拿到关系记录对应的AR单据。
  2. 筛选当前案例:通过CRRelation.refNoteID == Current<CRCase.noteID>筛选出当前打开案例下的所有CRRelation记录,进而关联出所有对应的ARRegister数据。
  3. 网格绑定:确保“CAM Info”网格的数据源属性设置为修改后的CAMRelationsView。

内容的提问来源于stack exchange,提问作者Net Admin

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 16:20:31