Acumatica 将条件添加到PXSelect

Acumatica 将条件添加到PXSelect,acumatica,Acumatica,我试图向SOShipmentEntry图上定义的PXSelect添加一个条件。我读到我可以重新定义PXSelect,它会用我的值覆盖原始值,但这似乎没有发生 我像往常一样创建了图形扩展,然后用额外的“和”定义了PXSelect,我需要这样: public PXSelectJoin<SOShipmentPlan, InnerJoin<SOLineSplit, On<SOLineSplit.planID, Equal<

我试图向SOShipmentEntry图上定义的PXSelect添加一个条件。我读到我可以重新定义PXSelect,它会用我的值覆盖原始值,但这似乎没有发生

我像往常一样创建了图形扩展,然后用额外的“和”定义了PXSelect,我需要这样:

   public PXSelectJoin<SOShipmentPlan,
                          InnerJoin<SOLineSplit, On<SOLineSplit.planID, Equal<SOShipmentPlan.planID>>,
                          InnerJoin<SOLine, On<SOLine.orderType, Equal<SOLineSplit.orderType>, And<SOLine.orderNbr, Equal<SOLineSplit.orderNbr>, And<SOLine.lineNbr, Equal<SOLineSplit.lineNbr>>>>,
                          InnerJoin<InventoryItem, On<InventoryItem.inventoryID, Equal<SOShipmentPlan.inventoryID>>,
                          LeftJoin<INLotSerClass,
                              On<InventoryItem.FK.LotSerClass>,
                          LeftJoin<INSite,
                              On<SOLine.FK.Site>,
                          LeftJoin<SOShipLine,
                                      On<SOShipLine.origOrderType, Equal<SOLineSplit.orderType>,
                                      And<SOShipLine.origOrderNbr, Equal<SOLineSplit.orderNbr>,
                                      And<SOShipLine.origLineNbr, Equal<SOLineSplit.lineNbr>,
                                      And<SOShipLine.origSplitLineNbr, Equal<SOLineSplit.splitLineNbr>,
                                      And<SOShipLine.confirmed, Equal<boolFalse>,
                                      And<SOShipLine.shipmentNbr, NotEqual<Current<SOShipment.shipmentNbr>>>>>>>>>>>>>>,
                          Where<SOShipmentPlan.siteID, Equal<Optional<SOOrderFilter.siteID>>,
                          And<SOShipmentPlan.planDate, LessEqual<Optional<SOOrderFilter.endDate>>,
                          And<SOShipmentPlan.orderType, Equal<Required<SOOrder.orderType>>,
                          And<SOShipmentPlan.orderNbr, Equal<Required<SOOrder.orderNbr>>,
                          And<SOLine.operation, Equal<Required<SOLine.operation>>,
                          And<SOShipLine.origOrderNbr, IsNull,
                          And<SOLineExt.usrShipmentHold, NotEqual<True>>
                          >>>>>>> ShipmentScheduleSelect;
public PXSelectJoin ShipmentScheduleSelect;
编辑:在查看Samvel发布的代码后,我在网上找到了一些附加信息,并在下面创建了一个委托方法。但是,当运行此命令时,我会收到一条消息,说明找不到SiteID,并且SiteID显示为空。当我逐步浏览代码时,PXView似乎包含了预期传入的所有参数。这几乎像是参数被删除了。我也尝试将参数复制到一个新数组中,但也没有成功。有什么想法吗

    public IEnumerable shipmentScheduleSelect()
    {
        PXView select = new PXView(Base, true, Base.ShipmentScheduleSelect.View.BqlSelect);

        select.BqlSelect.WhereAnd(typeof(Where<SOLineExt.usrShipmentHold, NotEqual<True>>));

        Int32 totalrow = 0;
        Int32 startrow = PXView.StartRow;
        List<object> result = select.Select(PXView.Currents, PXView.Parameters,
               PXView.Searches, PXView.SortColumns, PXView.Descendings,
               PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow);
        PXView.StartRow = 0;
        return result;
    }
public IEnumerable shipmentScheduleSelect()
{
PXView select=新PXView(Base、true、Base.ShipmentScheduleSelect.View.BqlSelect);
select.BqlSelect.wherend(typeof(Where));
Int32 totalrow=0;
Int32 startrow=PXView.startrow;
列表结果=选择。选择(PXView.Currents,PXView.Parameters,
PXView.Searches,PXView.SortColumns,PXView.degensions,
PXView.Filters、ref startrow、PXView.maximumrrows、ref totalrow);
PXView.StartRow=0;
返回结果;
}

请参见下面的示例,说明如何在此特定情况下添加数据委托:

using System.Collections;
using System.Collections.Generic;
using PX.Data;
using PX.Objects.CS;
using PX.Objects.IN;

namespace PX.Objects.SO
{
    public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry>
    {
        #region Event Handlers
        public IEnumerable shipmentScheduleSelect()
        {
            throw new PXException("TEST EXCEPTION");
            /*
            Replace the PXException with the override of the select as you need. Below is just an example how you can do that but make sure to provide all the parameters to the select
            var cmd = new PXSelectJoin<SOShipmentPlan, InnerJoin<SOLineSplit, On<SOLineSplit.planID, Equal<SOShipmentPlan.planID>>,
                InnerJoin<SOLine, On<SOLine.orderType, Equal<SOLineSplit.orderType>, And<SOLine.orderNbr, Equal<SOLineSplit.orderNbr>, And<SOLine.lineNbr, Equal<SOLineSplit.lineNbr>>>>,
                InnerJoin<InventoryItem, On<InventoryItem.inventoryID, Equal<SOShipmentPlan.inventoryID>>,
                LeftJoin<INLotSerClass, On<InventoryItem.FK.LotSerialClass>, LeftJoin<INSite, On<SOLine.FK.Site>,
                LeftJoin<SOShipLine, On<SOShipLine.origOrderType, Equal<SOLineSplit.orderType>,
                    And<SOShipLine.origOrderNbr, Equal<SOLineSplit.orderNbr>,
                        And<SOShipLine.origLineNbr, Equal<SOLineSplit.lineNbr>,
                            And<SOShipLine.origSplitLineNbr, Equal<SOLineSplit.splitLineNbr>,
                                And<SOShipLine.confirmed, Equal<boolFalse>,
                                    And<SOShipLine.shipmentNbr, NotEqual<Current<SOShipment.shipmentNbr>>>>>>>>>>>>>>,
                Where<SOShipmentPlan.siteID, Equal<Optional<SOOrderFilter.siteID>>,
                    And<SOShipmentPlan.planDate, LessEqual<Optional<SOOrderFilter.endDate>>,
                        And<SOShipmentPlan.orderType, Equal<Required<SOOrder.orderType>>,
                            And<SOShipmentPlan.orderNbr, Equal<Required<SOOrder.orderNbr>>,
                                And<SOLine.operation, Equal<Required<SOLine.operation>>,
                                    And<SOShipLine.origOrderNbr, IsNull>>>>>>>(this.Base);
            List<object> pars = new List<object>(){
                siteId,
                endDate,
                orderType,
                orderNbr,
                operation
            };
            bool condition = true;
            if(condition)
            {
                cmd.WhereAnd(typeof(Where<InventoryItem.itemClassID, Equal<Required<InventoryItem.itemClassID>>>));
                pars.Add("TEST_ITEM_CLASS");
            }
            return cmd.Select(pars.ToArray());
            */
        }
        #endregion
    }
}
使用系统集合;
使用System.Collections.Generic;
使用PX数据;
使用PX.Objects.CS;
使用PX.Objects.IN;
命名空间PX.Objects.SO
{
公共类SOShipmentEntry_扩展:pXgrapherExtension
{
#区域事件处理程序
公共IEnumerable shipmentScheduleSelect()
{
抛出新的PXException(“测试异常”);
/*
根据需要使用select的覆盖替换PXException。下面只是一个示例,说明如何执行此操作,但请确保向select提供所有参数
var cmd=new PXSelectJoin(this.Base);
列表PAR=新列表(){
站点ID,
结束日期,
订单类型,
订单编号:,
活动
};
布尔条件=真;
如果(条件)
{
cmd.WHEREND(类型(其中));
增加部分(“测试项目”类别);
}
返回cmd.Select(pars.ToArray());
*/
}
#端区
}
}

您可以覆盖数据委托,该数据委托将是具有相同名称的函数,如
shipmentScheduleSelect
。我试过几种方法。其中一个我使用了[PXOverride]属性,收到错误“图扩展中的方法System.Collections.IEnumerable shipmentScheduleSelect()标记为[PXOverride],但在PXGraph中找不到具有此名称的原始方法”。然后我尝试不使用PXOverride属性,收到消息“未找到字段:'PX.Objects.SO.SOShipmentEntry.ShipmentScheduleSelect'”。我将其创建为“public IEnumerable shipmentScheduleSelect()”。如果希望限制始终处于活动状态,可以在要限制的DAC上使用CacheAttached,并将该条件置于PXRestrictor属性中。这个限制器可以是有条件的,它不太可能因升级而中断,而不是覆盖整个视图。如果需要将另一个DAC添加到select中,我建议仅覆盖整个视图,我也建议您只需非常小心地执行此操作。如果您需要PXRestrictor的示例,请提供您的条件限制的一些上下文。嗨,Samvel,谢谢您提供的信息。我想这让我走上了正确的道路。但是,现在我得到一个错误,说SiteID不存在。我确认我在参数数组中正确地传递了它,并且我传递的站点ID确实存在。你知道为什么找不到这个网站吗?这和基地缓存中的电流有关吗?