在流程装运中添加其他过滤器字段 [英] Adding additional filter field on process shipments

查看:90
本文介绍了在流程装运中添加其他过滤器字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我向SOShipment和SOShipmentFilter添加了一个新的自定义字段。我正在尝试使用它来过滤处理货件的网格,并且代码有问题。我在扩展代码的地方进行了其他自定义,但是我可以先调用baseHandler,然后在返回时执行我的代码段。但是,当我重写委托函数时,它只是设置了一个模板,并返回了baseMethod。当我在代码中加入新的过滤器字段时,会出现未定义字段/引用的编译错误。我是否需要从原始委托中复制所有原始代码,并将其包含在我的重写函数中?以下是我当前的覆盖代码:

I have added a new custom field to SOShipment and SOShipmentFilter. I am trying to use it to filter the grid for Process Shipments and I am having problems with the code. I have done other customizations where I have extended code but I was able to call the baseHandler first and then execute my snippet when it returned. However when I override the delegate function, it just sets up a template with a return to baseMethod. When I put my code in to include the new filter field, I get compile errors for undefined fields/references. Do I need to copy all of the original code from the original delegate and include it in my override function? Below is my current override code:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using PX.Data;
using PX.Objects.CS;
using PX.Objects.IN;
using PX.Objects.AR;
using PX.Objects.CM;
using POReceipt = PX.Objects.PO.POReceipt;
using POReceiptLine = PX.Objects.PO.POReceiptLine;
using POLineType = PX.Objects.PO.POLineType;
using PX.Objects;
using PX.Objects.SO;

namespace PX.Objects.SO
{
  public class SOInvoiceShipment_Extension:PXGraphExtension<SOInvoiceShipment>
  {
    #region Event Handlers
    public delegate IEnumerable ordersDelegate();
    [PXOverride]
    public IEnumerable orders(ordersDelegate baseMethod)
    {
      if (filter.usrTruckNbr != null)
      {
        ((PXSelectBase<SOShipment>)cmd).WhereAnd<Where<SOShipment.usrTruckNbr, GreaterEqual<Current<SOShipmentFilter.usrTruckNbr>>>>();
      }
      return baseMethod();
    }
    protected virtual void SOShipmentFilter_UsrTruckNbr_CacheAttached(PXCache cache)
    {

    }
    #endregion
  }
}


推荐答案

cmd 是位置变量,您不能从扩展程序中访问它。我看到两种方法可以达到所需的结果:

cmd is a location variable and you cannot access it from your extension. I see two ways you could achieve the result you want:


  1. 将整个委托函数复制到扩展中。这是不理想的,因为必须使用Acumatica的每个新版本进行验证和更新。

  2. 在从原始委托返回后但在客户端之前过滤客户端数据它显示在屏幕上。这不如对SQL进行过滤有效,但至少可以消除将太多代码复制到扩展中的需要。这是一个完整的示例,该示例将过滤货运清单以仅返回货运量均匀的单据:

  1. Copy the whole delegate function to your extension. This is not ideal because it will have to be verified and updated with every new version of Acumatica.
  2. Filter data on the client side after it is returned from the original delegate but before it is displayed on screen. This is not as efficient as filtering on SQL but at least would remove the need to copy too much code to your extension. Here's a complete sample which will filter the list of shipments to return only documents where shipment quantity is even:

public class SOInvoiceShipment_Extension : PXGraphExtension<SOInvoiceShipment>
{
    [PXFilterable]
    public PXFilteredProcessing<SOShipment, SOShipmentFilter> Orders;

    protected IEnumerable orders()
    {
        // Filter the list of shipments to return only documents where shipment quantity is even
        foreach (SOShipment shipment in Base.Orders.Select())
        {            
            if(shipment.ShipmentQty % 2 == 0)
            {
                yield return shipment;
            }
        }
    }

    public void SOShipmentFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
    {
        if (e.Row == null) return;

        SOShipmentFilter filter = e.Row as SOShipmentFilter;
        if (filter != null && !string.IsNullOrEmpty(filter.Action))
        {
            Dictionary<string, object> parameters = Base.Filter.Cache.ToDictionary(filter);
            Orders.SetProcessTarget(null, null, null, filter.Action, parameters);
        }
    }
}


在所有情况下,都不应使用PXOverride覆盖视图委托;不幸的是,当您尝试覆盖委托时,定制工具会生成错误的方法签名,这将得到改善。您应参阅此处可获得的T300培训,以获取有关此类定制的更多信息(请参见声明或更改BLC数据视图委托。

In all cases, you should not use PXOverride to override the view delegate; the customization tools unfortunately generate the wrong method signature when you try to override a delegate, and this will be improved. You should refer to the T300 training available here for more information on this type of customization (look for "Declaring or Altering a BLC Data View Delegate).

这篇关于在流程装运中添加其他过滤器字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆