如何从报表设计器调用Acumatica函数? [英] How to call Acumatica function from Report Designer?

查看:42
本文介绍了如何从报表设计器调用Acumatica函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Acumatica编写的Common函数,我们在各种Acumatica屏幕上使用了该函数,我们希望在报表设计器中使用此函数,以便我们可以打印该值。
示例:CheckBday()如果​​我们通过客户代码,它将检查该客户生日字段,如果是今天,则返回生日快乐

I have a Common function written in Acumatica and we use that on various Acumatica screen, we would like to use this function in report designer so we could print the value. Example: CheckBday() If we pass a customer code it shld check this customer birthday field and if it's today then it returns "Happy Birthday"

是可以在报表设计器中调用此通用函数进行处理?如果是这样,如何在报表设计器中实现,则任何见解都将有所帮助。

Is it possible to call this common function in report designer to process? If so how can this be achieved in the report designer, any insight will be helpful.

推荐答案

您可以在报表上使用扩展功能通过使用用户定义函数(UDF)进行设计。
您可以:

You can use extended functions on Report Designer by using User Define Functions(UDF). You could:


  1. 创建一个新的AddOn项目,称为ReportUDF。添加一个名为UtilFunctions.cs的新类文件。

  2. 添加公共函数YOURFUNCTION:

  1. Create a new AddOn project called ReportUDF. Add a new class file called UtilFunctions.cs.
  2. Add public function YOURFUNCTION:

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using PX.Objects.AP;

 namespace ReportUDF
 {
    public class UtilFunctions
    {
        public string YOURFUNCTION(string PARAM)
        {
            try
            {
                 //function code
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
     }
}


  • 参数及其数据类型:
    类中的方法应始终包含string类型的参数,并始终返回string类型的值。处理参数和返回参数的最佳方法是将它们声明为Object类型。但是,在使用或使用它们之前,需要将这些参数转换为适当的数据类型,以确保方法的正确操作。

  • Parameters and Their Data Types: Methods in your class should always contain parameters of type string and always return a value of type string. The best way to handle the parameters and return parameters are by declaring them of the Object type. However, you will need to convert these parameters to the appropriate data types before consuming or using them to ensure proper operation of your methods.

    编译此加载项项目。成功编译后,确保将程序集(ReportUDF.dll)放在Acumatica网站的Bin文件夹中。

    Compile this Add-On Project. Upon successful compile, ensure the assembly (ReportUDF.dll) is placed in the Bin folder of Acumatica website.

    在ReportLauncher.aspx中连接此新程序集。 cs如下所述:

    Wire up this new assembly in ReportLauncher.aspx.cs as described below:


    • 在Visual Studio中打开ReportLauncher.aspx.cs文件(网站文件夹>框架)。

    • 将以下代码行添加到静态构造函数Pages_ReportLauncer的底部:

    • Open ReportLauncher.aspx.cs file (Website Folder > Frames) in Visual Studio.
    • Add the following lines of code to the bottom of the static constructor Pages_ReportLauncer:

     Type DemoReportFunctionsType =
     System.Web.Compilation.BuildManager.GetType("ReportUDF.UtilFunctions", false);
    
     if(DemoReportFunctionsType != null)
     {      
         ExpressionContext.RegisterExternalObject("ReportUDF",Activator.CreateInstance(DemoReportFunctionsType));
     }
    


  • 打开您在报表设计器中的窗体报表,并添加具有以下表达式的TextBox控件,如下所示:

    Open your form report in Report Designer and add TextBox control with following expression as shown below:

     = ReportUDF.YOURFUNCTION([DAC.UsrSomeField])
    


    观察:

    Observation: UDFs do not show up in the Expression Editor.


    1. 保存并运行报告。

    观察:自定义ReportLauncher.aspx.cs不是标准做法,应重新应用升级期间的更改。您始终可以将这些更改作为定制包的一部分进行编译。但是,您应确保在升级过程中保留对此代码文件的增强功能(如果有)。否则报告可能无法按预期运行。

    Observation: Customizing ReportLauncher.aspx.cs is not a standard practice and changes during upgrades should be reapplied. You can always compile these changes as part of a customization package; however, you should ensure that enhancements (if any are present) to this code file are preserved during upgrades. Otherwise reports may not function as expected.

    这篇关于如何从报表设计器调用Acumatica函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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