函数“MoveNext”中发生了未处理的异常。有关详细信息,请参阅跟踪日志

时间:2018-04-14 10:57:24

标签: acumatica

我有一个自定义项目,要求我只显示已在商业帐户中添加的自定义选项卡中设置的数据(如商机)。我已经设法使用数据视图委托和自定义选择器来遵守这些规则,错误发生在:

1。)单击机会ID,其中自定义限制通用查询中的此类数据。 2.)单击商机模块中的下一个或上一个按钮

这是代码

protected virtual IEnumerable opportunity()
    {
        var output = new PXSelect<CROpportunity>(Base);
        foreach (CROpportunity _output in output.Select())
        {
            bool returnOutput = false;
            var memberships = PXSelectJoinGroupBy<EPEmployee, RightJoin<EPCompanyTreeMember, On<EPCompanyTreeMember.userID, Equal<EPEmployee.userID>>>, Where<EPEmployee.userID, Equal<Current<AccessInfo.userID>>>, Aggregate<GroupBy<EPCompanyTreeMember.workGroupID>>>.Select(Base);
            foreach (PXResult<EPEmployee, EPCompanyTreeMember> member in memberships)
            {
                EPCompanyTreeMember _member = (EPCompanyTreeMember)member;
                BAccountRestriction2 visible = PXSelect<BAccountRestriction2, Where<BAccountRestriction2.account, Equal<Required<BAccount.bAccountID>>, And<BAccountRestriction2.child, Equal<Required<BAccountRestriction2.child>>>>>.Select(Base, ((CROpportunity)_output).BAccountID, _member.WorkGroupID);
                if (visible != null || ((CROpportunity)_output).OpportunityID == " <NEW>")
                {

                    returnOutput = true;
                    break;
                }

            }
            if (returnOutput)
            {
                yield return _output;
            }
        }


    }

这是自定义选择器

 public class OpportunityMaintExtension : PXGraphExtension<OpportunityMaint>
{

    #region custom selector
    public class PXCustomSelectorOpportunityAttribute : PXCustomSelectorAttribute
    {
        public PXCustomSelectorOpportunityAttribute()
            : base(typeof(CROpportunity.opportunityID)
               , new[] { typeof(CROpportunity.opportunityID), 
            typeof(CROpportunity.opportunityName),
            typeof(CROpportunity.status), 
            typeof(CROpportunity.curyAmount),
            typeof(CROpportunity.curyID), 
            typeof(CROpportunity.closeDate),
            typeof(CROpportunity.stageID),
            typeof(CROpportunity.cROpportunityClassID),
            typeof(BAccount.acctName),
            typeof(Contact.displayName) }
            )
        {
            //this.DescriptionField = typeof(CQHRISLeave.refNbr);
        }
        protected virtual IEnumerable GetRecords()
        {
            foreach (var pc in this._Graph.GetExtension<OpportunityMaintExtension>().opportunity())
            {
                if (((CROpportunity)pc).OpportunityID != " <NEW>")
                    yield return pc as CROpportunity;
            }
        }


    }
    #endregion

然后自定义选择器属性的实现在这里:

 public class CROpportunityExtension : PXCacheExtension<CROpportunity>
{
    #region OpportunityID

    public abstract class opportunityID : PX.Data.IBqlField { }

    public const int OpportunityIDLength = 10;

    [PXDBString(OpportunityIDLength, IsUnicode = true, IsKey = true, InputMask = ">CCCCCCCCCCCCCCC")]
    [PXUIField(DisplayName = "Opportunity ID", Visibility = PXUIVisibility.SelectorVisible)]
    [AutoNumber(typeof(CRSetup.opportunityNumberingID), typeof(AccessInfo.businessDate))]
    [NORDE.OpportunityMaintExtension.PXCustomSelectorOpportunity]
    [PXFieldDescription]
    public virtual String OpportunityID { get; set; }
    #endregion
}

1 个答案:

答案 0 :(得分:0)

我成功地解决了#34;通过在此页面上禁用通用查询来解决此问题。最初,“机会”页面是一般查询,由于某种原因,它可能已经影响了缓存或数据视图委托并引发错误。

我只是:编辑通用查询 - &gt;入口点标签 - &gt;取消选中&#34;在菜单&#34;

中使用此Inuiry替换输入屏幕