Custom Function for Combination as Character String

  • Last update:October 30, 2025
  • Overview

    Expected Effect

    You can use the StringCat function in FineBI to combine strings, for example, to combine Contract ID and Contract Payment Type from Contract Information together as a single field, as shown in the following figure.

    3.1.1.png

    Untitled.png

    Implementation Method

    Since the Function interface is implemented in the AbstractFunction class, the StringCat function can directly inherit the AbstractFunction class.

    When you use the function StringCat(Para,Para,Para…), the system obtains the StringCat class that performs the operation based on the function name, passes parameters into the args object array in the class, and execute the run function of the class. In the run function, the input parameters are combined as a character string, and returns the final combined string.

    iconNote:
    For details about the rules and notes for defining custom functions, see Custom Function Introduction.

    Function Description

    The StringCat function is used to combine all parameters into a string.

    The StringCat function is used in the form of StringCat(Para,Para,Para...), where Para is a parameter of the function, and the number of parameters is unlimited.

    Example: Method One

    iconNote:
    This solution is not supported in FineBI installed using the EXE installation package.

    Writing the Java File

    Write StringCat.java. The function code is as follows:

    package com.fr.function;
    import com.fr.script.AbstractFunction;
    public class StringCat extends AbstractFunction {
    public Object run(Object[] args) {
    String result = "";
    Object para;
    for (int i = 0; i < args.length; i++) {
    para = args[i];
    result += para.toString();
    }
    return result;
    }
    }

    Compiling a CLASS File

    Preparing the Compilation Environment

    For details, see Compiling Java Program.

    Generating a CLASS File

    Compile StringCat.java to generate the StringCat.class file.

    Importing a CLASS File

    Place the compiled StringCat.class file into FineBI installation directory\webapps\webroot\WEB-INF\classes\com\fr\function, as shown in the following figure.

    iconNote:
    If there is no corresponding directory in the WEB-INF directory, create one.

     3.1.png

    Using the Custom Function

    After restarting FineBI, you can use the custom function directly. The usage of the custom function is the same as that of the built-in function.

    For example, when adding calculated indicators, you can see the previously defined function Stringcat in Other Function. Click the function to add it to the formula, as shown in the following figure.

     3.2.png

    To combine Contract ID and Contract Payment Type from Contract Information into a single field, enter the formula: StringCat(Contract ID," ",Contract Payment Type), as shown in the following figure.

     3.3.png

    Effect Display

    For details, see section "Expected Effect".

    Example: Method Two

    Refer to sections "Writing the Java File", "Compilation Environment Preparation", and "Generating a class File" to compile and generate a StringCat.class file.

    Importing a CLASS File

    Place the StringCat.class file in the directory FineBI installation directory\webapps\webroot\WEB-INF\classes\com\fr\function, as shown in the following figure.

     3.4.png

    The file can be placed in any location in the FineBI project directory, but it must correspond to the location in the package in the java file. For example, the code in this example is:

    package com.fr.function;

    Therefore, you need to place the CLASS file in FineBI installation directory\webapps\webroot\WEB-INF\classes\com\fr\function directory.

    Similarly, you need to place the CLASS file in FineBI installation directory\webapps\webroot\WEB-INF\classes\com when the code is:

    package com;

    Registering a Custom Function

    After the CLASS file for the function is generated, you need to register the custom function in the FineReport designer for use.

    Build remote connection between the FineReport designer and the FineBI project. Choose Server > Function Manager, add a function named StringCat, select the defined StringCat class, and click OK, as shown in the following figure.

     3.5.png

    Using a Custom Function

    After restarting FineBI, you can use the custom function directly. The usage of the custom function is the same as that of the built-in function.

    iconNote:
    After registration, you can still use the custom function even after canceling the remote connection.

    Effect Display

    For details, see section "Expected Effect".

     


    附件列表


    主题: System Management
    Previous
    Next
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy