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

Acumatica自定义筛选处理屏幕调度报错:Value cannot be null(key参数)

Acumatica自定义筛选处理屏幕自动调度的NullKey错误解决

错误信息

设置自动调度时抛出异常:

12/20/2022 11:09:19 AM Error:
Value cannot be null.
Parameter name: key

   at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at PX.Data.PXViewCollection.TryGetOrCreateValue(String key, PXView& value)
   at PX.Data.PXViewCollection.get_Item(String key)
   at PX.SM.AUScheduleMaint.OnScreenIdChanged(PXCache sender, AUSchedule schedule)
   at PX.Data.PXCache.OnRowInserted(Object item, Object pending, Boolean externalCall)
   at PX.Data.PXCache`1.Insert(Object data, Boolean bypassinterceptor)
   at PX.Data.PXCache`1.Insert(Object data)
   at PX.Data.PXSelectBase`1.Insert(Table item)
   at PX.Data.PXFilteredProcessing`2._ScheduleAdd_(PXAdapter adapter)
   at PX.Data.PXAction`1.RunHandler(PXAdapter adapter)
   at PX.Data.PXAction`1.d__28.MoveNext()
   at PX.Data.PXAction`1.d__28.MoveNext()
   at PX.Data.PXAction`1.d__28.MoveNext()
   at PX.Data.PXAction`1.d__28.MoveNext()
   at PX.Web.UI.PXBaseDataSource.tryExecutePendingCommand(String viewName, String[] sortcolumns, Boolean[] descendings, Object[] searches, Object[] parameters, PXFilterRow[] filters, DataSourceSelectArguments arguments, Boolean& closeWindowRequired, Int32& adapterStartRow, Int32& adapterTotalRows) in C:\Users\svc-builder\AppData\Local\Temp\~PX.Web..1\PX.Web.UI.dll.il:line 110930
   at PX.Web.UI.PXBaseDataSource.ExecuteSelect(String viewName, DataSourceSelectArguments arguments, PXDSSelectArguments pxarguments) in C:\Users\svc-builder\AppData\Local\Temp\~PX.Web..1\PX.Web.UI.dll.il:line 108573

当前配置说明

  • 主DAC的OperationID字段已标记[PXDBInt(IsKey = true)],对应SQL表中为主键
  • 筛选DAC的OperationID标记了[PXInt(IsKey = true)]

相关代码

筛选DAC

public class NGZoomProcessingFilter : IBqlTable
{
    #region OperationID

    [PXInt(IsKey = true)]
    [PXUIField(DisplayName = "Operation ID")]
    [OperationIDEntityType]
    public virtual int? OperationID { get; set; }

    public abstract class operationID : 
PX.Data.BQL.BqlInt.Field<operationID>
    {
    }

    #endregion

    #region OverrideLastRunDate

    [PXDate()]
    [PXUIField(DisplayName = "Override Last Run")]
    public virtual DateTime? OverrideLastRunDate { get; set; }

    public abstract class overrideLastRunDate : 
PX.Data.BQL.BqlDateTime.Field<overrideLastRunDate>
    {
    }

    #endregion
}

主DAC

[Serializable]
[PXCacheName("Zoom Processing Routine")]
public class NGZoomProcessingRoutine : IBqlTable
{
    public class PK : 
PrimaryKeyOf<NGZoomProcessingRoutine>.By<operationID>
    {
        public static NGZoomProcessingRoutine Find(
            PXGraph graph, int? operationID)
            => FindBy(graph, operationID);
    }

    #region Selected

    [PXBool]
    [PXUnboundDefault(false)]
    [PXUIField(DisplayName = "Selected")]
    public virtual bool? Selected { get; set; }

    public abstract class selected : BqlBool.Field<selected>
    {
    }

    #endregion

    #region OperationID

    [PXDBInt(IsKey = true)]
    [PXUIField(DisplayName = "Operation ID")]
    [OperationIDEntityType]
    public virtual int? OperationID { get; set; }

    public abstract class operationID : 
PX.Data.BQL.BqlInt.Field<operationID>
    {
    }

    #endregion

    #region LastRun

    [PXDBDate()]
    [PXUIField(DisplayName = "Last Run")]
    public virtual DateTime? LastRun { get; set; }

    public abstract class lastRun : 
PX.Data.BQL.BqlDateTime.Field<lastRun>
    {
    }

    #endregion
}

Graph代码

//PrepareDataScreen
public class NGZoomProcessing : PXGraph<NGZoomProcessing>
{
    public PXCancel<NGZoomProcessingFilter> Cancel;

    public PXFilter<NGZoomProcessingFilter> Filter;
    public PXFilteredProcessing<NGZoomProcessingRoutine, NGZoomProcessingFilter> ProcessingRoutine;

    public PXSetup<NGZoomProcessingSettings> Settings;

    public SelectFrom<NGPgtAIntroWebinarParticipant>.View Participants;

    public SelectFrom<NGPgtAIntroWebinarInstance>.View Webinars;

    protected void _(Events.RowSelected<NGZoomProcessingFilter> e)
    {
        if (e.Row is null) return;
        DateTime? lastRunDate = null;
        if (e.Row.OverrideLastRunDate is not null)
        {
            lastRunDate = e.Row.OverrideLastRunDate;
        }

        ProcessingRoutine.SetProcessDelegate((list) => SyncWebinars(list, lastRunDate));
    }
}

解决方案

这个错误的核心原因是调度系统无法获取筛选DAC的有效键值,因为筛选DAC的键字段未绑定到数据库,导致调度创建时无法持久化和读取筛选条件的键。

步骤1:修改筛选DAC的键字段属性

将筛选DAC中OperationID的[PXInt(IsKey = true)]改为[PXDBInt(IsKey = true)],确保字段能被持久化到数据库:

[PXDBInt(IsKey = true)]
[PXUIField(DisplayName = "Operation ID")]
[OperationIDEntityType]
public virtual int? OperationID { get; set; }

步骤2:验证筛选条件的键值有效性

在创建调度前,确保筛选的OperationID字段有非空值,避免空键被传递给调度系统。

步骤3:检查Graph的调度关联逻辑

确保PXFilteredProcessing控件正确关联筛选DAC的键字段,调度系统需要通过这个键来唯一标识调度对应的筛选条件。


内容的提问来源于stack exchange,提问作者Keelan Christensen

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 19:01:10