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.
You can use extended functions on Report Designer by using User Define Functions(UDF). You could:
Add public function YOURFUNCTION:
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.
Compile this Add-On Project. Upon successful compile, ensure the assembly (ReportUDF.dll) is placed in the Bin folder of Acumatica website.
Wire up this new assembly in ReportLauncher.aspx.cs as described below:
Add the following lines of code to the bottom of the static constructor Pages_ReportLauncer:
Open your form report in Report Designer and add TextBox control with following expression as shown below:
Observation: UDFs do not show up in the Expression Editor.
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.
As @cbetabeta mentioned, using
Reports User Defined Function(UDF)
is one of the possible approach. But maintaining customizedReportLauncher.aspx.cs
version to version would be a challenge.Alternate possible approach for this could be via unbound DAC field having
PXFormula
/PXDBScalar
/PXDBCalced
attribute. You could use custom BQL Function (derived fromBqlFormulaEvaluator
) as well – You can refer out-of-box custom BQL functions available in formula sub-folder ofPX.Objects
source code. Or you can refer KB article where such custom BQL functionHierarchySorting
is used.