【问题标题】:Acumatica - Add Reports dropdown to Kit Assembly ScreenAcumatica - 将报告下拉列表添加到套件组装屏幕
【发布时间】:2018-09-06 05:33:01
【问题描述】:

我一直在尝试将报告下拉菜单添加到套件组装屏幕 (IN307000)。我们有基于 KitInventoryID 的自定义报告,这些报告将生成以打印标签,这些报告需要添加到屏幕的操作中。我注意到在大多数报告屏幕中通常都会有一个用于传输数据的传输,所以我确实在顶部写了我自己的声明。这是我目前所拥有的:

using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using PX.Data;
using PX.Objects.CS;
using PX.Objects.IN.Overrides.INDocumentRelease;
using PX.Objects.GL;
using PX.Objects.CM;
using System.Diagnostics;
using PX.Objects;
using PX.Objects.IN;

namespace PX.Objects.IN
{

  public class KitAssemblyEntry_Extension:PXGraphExtension<KitAssemblyEntry>
  {
  public PXSelect<INKitRegister, Where<INKitRegister.docType, Equal<Current<INKitRegister.docType>>, And<INKitRegister.kitInventoryID, Equal<Current<INKitRegister.kitInventoryID>>>>> transfer;
  public override void Initialize()
    {
        Report.AddMenuAction(MasterTag);
        Report.MenuAutoOpen = true;
    }

    #region Event Handlers

    public PXAction<INKitRegister> Report;
    [PXButton]
    [PXUIField(DisplayName = "Print Tag", MapEnableRights = PXCacheRights.Select)]
    protected void report()
    { }

    public PXAction<INKitRegister> MasterTag;
    [PXUIField(DisplayName = "Sample/Value Tag", MapEnableRights = PXCacheRights.Select)]
    [PXLookupButton]
    public virtual IEnumerable masterTag(PXAdapter adapter)
    {
      INKitRegister doc = Base.transfer.Current;
        if (doc != null)
        {
        Dictionary<string, string> parameters = new Dictionary<string, string>();
        parameters["DocType"] = this.transfer.Current.DocType;
        parameters["ItemNumber"] = this.transfer.Current.KitInventoryID.ToString();
        throw new PXReportRequiredException(parameters, "IN610004", "Sample/Value Tag");
        }

    }

    #endregion

  }


}

但是,当我尝试发布时,我收到了这个错误:

Building directory '\WebSiteValidationDomain\App_RuntimeCode\'.
\App_RuntimeCode\KitAssemblyEntry.cs(39): error CS1061: 'PX.Objects.IN.KitAssemblyEntry' does not contain a definition for 'transfer' and no extension method 'transfer' accepting a first argument of type 'PX.Objects.IN.KitAssemblyEntry' could be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\KitAssemblyEntry.cs(39): error CS1061: 'PX.Objects.IN.KitAssemblyEntry' does not contain a definition for 'transfer' and no extension method 'transfer' accepting a first argument of type 'PX.Objects.IN.KitAssemblyEntry' could be found (are you missing a using directive or an assembly reference?)

我也尝试将INKitRegister doc = Base.transfer.Current;更改为INKitRegister doc = Base.Document.Current;,但出现此错误:

\App_RuntimeCode\KitAssemblyEntry.cs(37): error CS0161: 'PX.Objects.IN.KitAssemblyEntry_Extension.masterTag(PX.Data.PXAdapter)': not all code paths return a value
\App_RuntimeCode\KitAssemblyEntry.cs(37): error CS0161: 'PX.Objects.IN.KitAssemblyEntry_Extension.masterTag(PX.Data.PXAdapter)': not all code paths return a value

【问题讨论】:

  • Transfer 是一个 DataView,根据错误与 Document 不同,它不是 KitAssemblyEntry 图的 DataView。虽然它可用于获取报告参数,但它不是报告子系统的一部分。关于“代码路径”的第二个错误发生是因为您在 masterTag 方法声明上有一个 IEnumerable 返回类型,但是当 doc 为 null 时方法定义可能不返回任何内容。这在 C# 中是不允许的,您必须确保方法的所有代码路径都返回 IEnumerable 或 null 引用以满足方法协定。
  • 在方法底部添加“return adapter.Get()”将符合编译器检查doc为null的情况。
  • 效果很好。我们只需要修改我们的报告。我会发布答案。谢谢!

标签: report customization acumatica


【解决方案1】:

这是固定的编码,它工作正常。

using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using PX.Data;
using PX.Objects.CS;
using PX.Objects.IN.Overrides.INDocumentRelease;
using PX.Objects.GL;
using PX.Objects.CM;
using System.Diagnostics;
using PX.Objects;
using PX.Objects.IN;

namespace PX.Objects.IN
{

  public class KitAssemblyEntry_Extension:PXGraphExtension<KitAssemblyEntry>
  {
  public PXSelect<INKitRegister, Where<INKitRegister.docType, Equal<Current<INKitRegister.docType>>, And<INKitRegister.kitInventoryID, Equal<Current<INKitRegister.kitInventoryID>>>>> transfer;
  public override void Initialize()
    {
        Report.AddMenuAction(MasterTag);
        Report.MenuAutoOpen = true;
    }

    #region Event Handlers

    public PXAction<INKitRegister> Report;
    [PXButton]
    [PXUIField(DisplayName = "Print Tag", MapEnableRights = PXCacheRights.Select)]
    protected void report()
    { }

    public PXAction<INKitRegister> MasterTag;
    [PXUIField(DisplayName = "Sample/Value Tag", MapEnableRights = PXCacheRights.Select)]
    [PXLookupButton]
    public virtual IEnumerable masterTag(PXAdapter adapter)
    {
      INKitRegister doc = Base.Document.Current;
        if (doc != null)
        {
        Dictionary<string, string> parameters = new Dictionary<string, string>();
        parameters["DocType"] = this.transfer.Current.DocType;
        parameters["ItemNumber"] = this.transfer.Current.KitInventoryID.ToString();
        throw new PXReportRequiredException(parameters, "IN610004", "Sample/Value Tag");
        }
     return adapter.Get();
    }

    #endregion

  }


}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-16
    • 1970-01-01
    • 2021-09-15
    • 2018-11-22
    相关资源
    最近更新 更多