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

Acumatica中如何通过自定义复选框字段限制PXSelector的员工选项?

问题解决:Acumatica中PXSelector引用自定义员工扩展字段报错

问题根源

你在EPEmployee上添加的UsrRegionManager是自定义扩展字段,原生EPEmployee实体类并不包含这个字段,直接在BQL中使用EPEmployee.usrRegionManager会导致编译报错。

解决方案步骤

  1. 确认EPEmployee扩展类定义
    首先确保你已经正确定义了EPEmployee的扩展类,示例如下:

    public class EPEmployeeExt : PXCacheExtension<PX.Objects.EP.EPEmployee>
    {
        #region UsrRegionManager
        [PXDBBool]
        [PXUIField(DisplayName = "Region Manager")]
        public virtual bool? UsrRegionManager { get; set; }
        public abstract class usrRegionManager : PX.Data.BQL.BqlBool.Field<usrRegionManager> { }
        #endregion
    }
    
  2. 修改ContractExt中的PXSelector查询
    在ContractExt的PXSelector中,需要通过扩展类引用自定义字段,替换原来的EPEmployee.usrRegionManager为EPEmployeeExt.usrRegionManager,同时确保扩展类的命名空间已被引用。

修改后的完整代码

using PX.Data;
using PX.Objects.CT;
using PX.Objects.EP;

// 确保引用EPEmployeeExt所在的命名空间,比如如果EPEmployeeExt在你的自定义命名空间下,需要添加using语句
// using YourCustomNamespace;

public class ContractExt : PXCacheExtension<Contract>
{
    #region UsrDefServiceManager
    [PXDBInt]
    [PXUIField(DisplayName = "Def Region Manager")]
    [PXSelector(
        typeof(Search<EPEmployee.bAccountID, 
            Where<EPEmployeeExt.usrRegionManager, Equal<True>>>), // 改用扩展类字段,直接用内置True常量
        typeof(EPEmployee.acctCD),
        typeof(EPEmployee.acctName),
        typeof(EPEmployee.vStatus),
        typeof(EPEmployee.departmentID),
        SubstituteKey = typeof(EPEmployee.acctCD),
        DescriptionField = typeof(EPEmployee.acctName))]
    public virtual int? UsrDefServiceManager { get; set; }
    public abstract class usrDefServiceManager : PX.Data.BQL.BqlInt.Field<usrDefServiceManager> { }
    #endregion
}

额外说明

  • 无需自定义cbTrue常量,Acumatica内置了True和FalseBQL常量,直接使用即可。
  • 确保EPEmployeeExt类的访问修饰符为public,且所在命名空间被ContractExt正确引用。
  • 如果仍然报错,检查数据库中是否已经生成了对应的EPEmployee.UsrRegionManager字段(通过Acumatica的Customization Publish操作同步到数据库)。

内容的提问来源于stack exchange,提问作者John Wiles

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.24 07:54:10