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

Acumatica AP301000屏幕操作菜单添加自定义报表动作报错求解

需求说明

在账单与调整(Bills and Adjustments, AP301000)屏幕新增可跳转至报表的自定义操作,放置到Acumatica操作(Action)菜单的报表专属特殊文件夹位置。
截图1:操作菜单标注位置

故障表现
  • 初始实现代码运行后直接抛出运行时异常
    截图2:代码运行报错界面
  • 自定义项目屏幕编辑器中,AP301000屏幕的报表文件夹不显示布局属性
    截图3:AP301000屏幕编辑器界面
  • 当前运行环境为Acumatica 22.101.0085版本

初始实现代码如下:

public class APInvoiceEntry_Extension : PXGraphExtension<PX.Objects.AP.APInvoiceEntry>
    {
 public override void Initialize()
         {
            base.Initialize();

            //this added the report to the reports menu

            Base.report.AddMenuAction(SupplierInvoice);



        }
            
        public PXAction<PX.Objects.AP.APInvoice> SupplierInvoice;

        [PXButton(CommitChanges = true)]
        [PXUIField(DisplayName = "Supplier Invoice")]
        protected void supplierInvoice()
        {
            if (Base.Document.Current.RefNbr != string.Empty)
            {
                //create parameters for report! Check report by editing it to see what reports are needed
                Dictionary<string, string> parameters = new Dictionary<string, string>();

                parameters["RefNbr"] = Base.Document.Current.RefNbr.ToString();
                parameters["DocType"] = Base.Document.Current.DocType;

                //the report number gets set below and parameters are sent with


                throw new PXReportRequiredException(parameters, "AP641500");


            }
        }

        }
}
修复步骤
  1. 修正代码语法错误:原代码末尾多了一层多余的闭合大括号,会直接导致编译失败。
  2. 修正Action方法签名:22R1版本中挂载到系统菜单的PXAction必须符合标准签名,即接收PXAdapter类型参数、返回IEnumerable类型结果,原无参void签名会触发运行时参数匹配异常。
  3. 调整菜单挂载逻辑:22R1版本不要直接调用Base.report.AddMenuAction挂载自定义报表动作,需先定位到系统内置的Reports菜单节点,再将动作挂载到该节点下,避免和系统内置报表菜单的加载逻辑冲突。
  4. 屏幕编辑器中看不到Reports文件夹布局属性为22R1版本的正常表现,该文件夹是系统动态生成的虚拟菜单节点,不需要在屏幕编辑器中手动配置布局。

修正后的完整可运行代码如下:

public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry>
{
    public PXAction<APInvoice> SupplierInvoice;

    [PXButton(CommitChanges = true)]
    [PXUIField(DisplayName = "Supplier Invoice", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
    protected virtual IEnumerable supplierInvoice(PXAdapter adapter)
    {
        APInvoice currentDoc = Base.Document.Current;
        if (!string.IsNullOrEmpty(currentDoc?.RefNbr))
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>
            {
                ["RefNbr"] = currentDoc.RefNbr,
                ["DocType"] = currentDoc.DocType
            };
            throw new PXReportRequiredException(parameters, "AP641500", "Supplier Invoice");
        }
        return adapter.Get();
    }

    public override void Initialize()
    {
        base.Initialize();
        PXNamedMenu reportsMenu = Base.ActionsMenu.FindMenu("Reports");
        reportsMenu?.AddAction(SupplierInvoice);
    }
}

代码修改完成后重新发布自定义项目,清除浏览器缓存即可在操作菜单的Reports文件夹下看到新增的Supplier Invoice操作。如果操作未显示,检查对应角色的访问权限配置,为角色分配该自定义动作的访问权限即可。


内容的提问来源于stack exchange,提问作者Miss. Developer

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.28 11:39:39