Global API - FR

  • Last update:  2023-08-01
  • Version

    VersionFunctional Change

    11.0

    Different from 10.0 in:

    11.0 added interfaces including servletURL, serverURL, server, fineServletURL, and SessionMgr.getSessionID().

    11.0.7

    Added description of FVS template interface.

    Applicable to users who have installed the FVS Dashboard Edit Mode plugin of version 1.8.0 and later.

    11.0.9

    The remoteEvaluate interface supported the FVS Dashboard Edit Mode plugin of version 1.15.0 and later.

    11.0.10

    showDialog and doHyperlinkByGet parameters supported JSON.

    Notice:

    1. Application programming interfaces (API) mentioned in this article shall be used in the format of FR.xxx for general reports and dashboards (new version), and in the format of duchamp.xxx for FVS dashboard templates.

    2. For some interfaces, the FVS template parameter is in JSON format, while for general reports and dashboards, the parameter is in string format. For details, see the interface introduction below.

    servletURL

    Attribute

    servletURL

     GET ServletURL

    Parameter

    -

    -

    Returned value

    string

    Returns a string in a format like 

    /webroot/decision/view/report
    Example

    For general reports and dashboards:

    FR.servletURL;

    For FVS templates:

    duchamp.servletURL;

    Application

    -

    Mobile terminal

    Supported

    There is a difference between the return format of the mobile terminal and the PC terminal, such as /webroot/decision.

    serverURL


    Attribute

    servletURL

     GET ServletURL

    Parameter

    -

    -

    Returned value

    string

    Returns a string in a format like

    http://localhost:port
    Example

    For general reports and dashboards:

    FR.serverURL;

    For FVS templates:

    duchamp.serverURL;
    Application

    -

    Mobile terminal

    Not supported


    Server

    Attribute

    server

    GET Server

    Parameter

    -

    -

    Returned value

    string

    Returns a string in a format like

    http://localhost:port/webroot
    Example

    For general reports and dashboards:

    FR.server;

    For FVS templates:

    duchamp.server;
    Application

    -

    Mobile terminal

    Not supported

    fineServletURL

    Attribute

    fineServletURL

    GET fineServletURL

    Parameter

    -

    -

    Returned value

    string

    Returns a string in a format like

    /webroot/decision
    Example

    For general reports and dashboards:

    FR.fineServletURL;

    For FVS templates:

    duchamp.fineServletURL;
    Application

    -

    Mobile terminal

    Not supported

    SessionMgr.getSessionID   

    Method

    SessionMgr.getSessionID()

    GET sessionId

    Parameter

    -

    -

    Returned value

    string

    Returns a string in a format like

    62a0f071-c2c6-4623-91c3-3d58c6265c19
    Example

    For general reports and dashboards:

    FR.SessionMgr.getSessionID();

    For FVS templates:

    duchamp.SessionMgr.getSessionID();
    Application

    Click the button to print the report sessionId.
    Click to download the template.

    Print sessionId.cpt

    1643100549518443.gif

    Click to download the FVS template. 

    Print sessionId.fvs

    Screen Recording 2023-07-31 at 17.20.16.gif

    Mobile terminal

    Supported

    showDialog

    General Reports and Dashboards

    Method

    showDialog(title, width, height, innerContent)

    Open a dialog box

    Parameter

    title: string

    width: number

    height: number

    innerContent: iframe

    iconNote:
    In FineReport 11.0.10 and later versions, the parameters support JSON format, as shown below.

    {

    title:string,

    width:number,

    height:number,

    innerContent:iframe

    }

    title: title of the dialog box, string

    width: dialog width

    height: dialog height

    innerContent: dialog content, iframe tage. 

    If you want to open a report in the project, you need to add an iframe tag first.

    Returned value

    void

    Example

    Example 1: Open a dialog box with the title "Pop-up Window", width 600, height 400, where the content of the dialog box is "Hello World".  

    For general reports and dashboards:

    FR.showDialog("Pop-up Window",600,400,"Hello World");

    Example 2: Open a dialog box with the title "Region Sales Situation", width 700, height 500, where the content of the dialog box is the built-in template "GettingStarted.cpt".

    iconNote:
    Pay attention to avoid code format problems caused by line changes and modify the format when entering long codes in the designer, as shown below. 

    For general reports and dashboards:

    Create an iframe inside the dialog box. Name the iframe parameter and specify the width and height.
    var iframe = $("<iframe id='inp' name='inp' width='100%'
    height='100%' scrolling='no' frameborder='0'>");
    Add the src attribute to the iframe. Specify the path of the template to be displayed.
    iframe .attr("src", "/webroot/decision/view/report?viewlet=GettingStarted .cpt");
    Design the pop-up dialog box.
    FR.showDialog("Region Sales Situation",700,500, iframe);

    Application

    Click to button to open a dialog box with the title "Region Sales Situation", width 700, height 500, where the content of the dialog box is the built-in template "GettingStarted.cpt".

    For details, see JS implements data backfill after pop-up window.

    2.gif

    Mobile terminal

    Not supported

    FVS Templates

    Method

    showDialog(

    {

    title:string,

    width:number,

    height:number,

    innerContent:iframe

    }

    )

    Open a dialog box

    Parameter

    title:string

    width:number

    height:number

    innerContent:iframe

    title: title of the dialog box, string

    width: dialog width

    height: dialog height

    innerContent: dialog content, iframe tage. If you want to open a report in the project, you need to add an iframe tag first.

    Returned value

    string

    Example

    Example 1: Open a dialog box with the title "Pop-up Window", width 600, height 400, where the content of the dialog box is"Hello World". 

    duchamp.showDialog(
    {
    title:"Pop-up Window",
    width:600,
    height:400,
    innerContent:"Hello World"
    }
    )

    Example 2: Open a dialog box with the title "Popup of Region Sales Situation", width 700, height 500, where the content of the dialog box is the built-in template "GettingStarted.cpt".

    "use document";
    const iframe = document.createElement("iframe");
    iframe.width = "100%";
    iframe.height = "100%";
    iframe.scrolling = "no";
    iframe.frameborder = "0";
    iframe.src = "/webroot/decision/view/report?viewlet=GettingStarted.cpt";
    // Design the pop-up dialog box.
    duchamp.showDialog(
    {
    title:"Popup of Region Sales Situation"
    width:700,
    height:500,
    innerContent:iframe,
    }
    );
    Application

    Open a dialog box with the title "Popup of Region Sales Situation", width 700, height 500, where the content of the dialog box is the built-in template "GettingStarted.cpt".

    Click to download the template.  

    Click to open iframe dialog box.fvs

    Screen Recording 2023-07-31 at 17.27.42.gif

    Mobile terminal

    Not supported

    closeDialog

    Method

    closeDialog()

    Close the dialog

    Parameter

    -

    -

    Returned value

    void

    Example

    For general reports and dashboards:

    FR.closeDialog();

    For FVS templates:

    duchamp.closeDialog();
    Application

    Once you select the data, the dialog box will automatically close.

    For details, see JS implements data backfill after pop-up window.

    3.gif

    Mobile terminal

    Not supported

    doHyperlinkByGet

    General Reports and Dashboards

    Method

    doHyperlinkByGet(url,config,target,feature)

    Open a webpage using the GET method, on which you can establish parameter linkage and set page properties.

    Parameter

    URL: object

    config: object

    target: object

    feature: object

    iconNote:
    In FineReport 11.0.10 and later versions, the parameters support JSON format, as shown below.

    {

    URL: object

    config: object

    target: object

    feature: object

    }

    URL: URL or JSON hyperlink, required

    An example of supported absolute paths:

    http://192.168.100.1:8080/webroot/decision/view/report?viewlet=GettingStarted.cpt

    An example of supported relative paths: /webroot/decision/view/report?viewlet=GettingStarted.cpt

    config: The parameter to be linked. It can be omitted.

    target: The opening path of a hyperlink page. It can be omitted.

    • _dialog: Dialog

    • _self: Current page

    • Name of a certain iframe, which will be opened on the current page, and submitted using the POST method.

    feature: The attribute of the hyperlink opening path. It can be omitted.

    iconNote:
    The target and feature parameters are not supported on mobile terminals.


    Returned value

    void

    Example

    Open the built-in template GettingStarted.cpt and one report named "Region Sales Situation", where the parameter "East China" is linked, and set whether to display the parameter panel and open the parameter panel as a dialog if it is displayed, with the dialog width 700 and height 500:

    FR.doHyperlinkByGet({
    //Report path
    "url":"/webroot/decision/view/report?viewlet=GettingStarted.cpt",
    //Parameter
    "para":{
    "Region":"East China"
    },
    "target":"_dialog",    //Open as a dialog
    "feature":{
    "width":700,
    "height":500,
    "title":"Region Sales Situation"
    }
    })
    Application

    Click the button to open a dialog with the title "Region Sales Situation", width 700, height 500, where the content of the dialog box is the sales data of East China.

    For details, see JS Implementation Dialog Box Open Hyperlink.

    4.gif

    Mobile terminal

    Supported

    FVS Templates

    Method

    doHyperlinkByGet(

    {

    url:object,

    para:object,

    target:object,

    feature:object

    }

    )

    Open a webpage using the GET method, on which you can establish parameter linkage and set page properties.

     

    Parameter

    url:object

    para:object

    target:object

    feature:object

     

    URL: URL or JSON hyperlink, required.

    An example of supported absolute paths:

    http://192.168.100.1:8080/webroot/decision/view/report?viewlet=GettingStarted.cpt

    An example of supported relative paths: /webroot/decision/view/report?viewlet=GettingStarted.cpt

    para: The parameter to be linked. It can be omitted.

    target: The opening path of the hyperlink page. It can be omitted and it defaults to _dialog.

    • _dialog: Dialog

    • _self: Current page

    • Name of a certain iframe, which will be opened on the current page, and submitted using the POST method.

    feature: The attribute of the hyperlink opening path. It can be omitted.

    Returned value

    void

    Example

    Open the built-in template GettingStarted.cpt and one report named "Region Sales Situation", where the parameter "California" is linked, and set whether to display the parameter panel and open the parameter panel as a dialog if it is displayed, with the dialog width 700 and height 500:

    duchamp.doHyperlinkByGet({
    //Report path
    "url":"/webroot/decision/view/report?viewlet=GettingStarted.cpt",
    //Parameter
    "para":{
    "Region":"California"
    },
    "target":"_dialog",    //Open as a dialog
    "feature":{
    "width":700,
    "height":500,
    "title":"Region Sales Situation"
    }
    })
    Application

    Click the button to open a dialog with the title "Region Sales Situation", width 700, height 500, where the content of the dialog box is the sales data of California.

    Click to download the template. 

    Use GET to open a dialog box.fvs

    Screen Recording 2023-07-31 at 17.36.43.gif

    Mobile terminal

    Not supported

    doHyperlinkByPost

    General Reports and Dashboards

    Method

    doHyperlinkByPost(url,config,tar get,feature)

    Open a webpage using the POST method, on which you can establish parameter linkage and set page properties.

    Parameter

    URL: object

    config: object

    target: object

    feature: object

    URL: URL or JSON hyperlink, required.

    An example of supported absolute paths:

    http://192.168.100.1:8080/webroot/decision/view/report?viewlet=GettingStarted.cpt

    An example of supported relative paths:

    /webroot/decision/view/report?viewlet=GettingStarted.cpt

    config: The parameter to be linked. It can be omitted.

    target: The opening path of a hyperlink page. It can be omitted.

    • _dialog: Dialog

    • _self: Current page

    • Name of a certain iframe, which will be opened on the current page, and submitted using the POST method.

    feature: The attribute of the hyperlink opening path. It can be omitted.

    iconNote:
    The target and feature parameters are not supported on mobile terminals.


    Returned value

    void

    Example

    Open the built-in template GettingStarted.cpt and one report named "Region Sales Situation", where the parameter "East China" is linked, and set whether to display the parameter panel and open the parameter panel as a dialog if it is displayed, with the dialog width 700 and height 500:

    FR.doHyperlinkByPost({
    //Report path
    "url":"/webroot/decision/view/report?viewlet=GettingStarted.cpt",
    //Parameter
    "para":{
    "Region":"East China"
    },
    "target":"_dialog",    //Open as a dialog
    "feature":{
    "width":700,
    "height":500,
    "title":"Region Sales Situation"
    }
    })
    Application

    Click the button to open a dialog with the title "Region Sales Situation", width 700, height 500, where the content of the dialog box is the sales data of East China.

    For details, see JS Implementation Dialog Box Open Hyperlink.

    5.gif

    Mobile terminal

    Supported

    FVS Templates

    Method

    doHyperlinkByPost(

    {

    url:object,

    config:object,

    target:object,

    feature:object

    }

    )

    Open a webpage using the POST method, on which you can establish parameter linkage and set page properties.

    Parameter

    URL: object

    config: object

    target: object

    feature: object

    URL: URL or JSON hyperlink, required.

    An example of supported absolute paths:

    http://192.168.100.1:8080/webroot/decision/view/report?viewlet=GettingStarted.cpt

    An example of supported relative paths:

    /webroot/decision/view/report?viewlet=GettingStarted.cpt

    config: The parameter to be linked. It can be omitted.

    target: The opening path of the hyperlink page. It can be omitted and it defaults to _dialog.

    • _dialog: Dialog

    • _self: Current page

    • Name of a certain iframe, which will be opened on the current page, and submitted using the POST method.  

    feature: The attribute of the hyperlink opening path. It can be omitted.

    Returned value

    void

    Example

    Open the built-in template GettingStarted.cpt and one report named "Region Sales Situation", where the parameter "California" is linked, and set whether to display the parameter panel and open the parameter panel as a dialog if it is displayed, with the dialog width 700 and height 500:

    duchamp.doHyperlinkByPost({
    //Report path
    "url":"/webroot/decision/view/report?viewlet=GettingStarted.cpt",
    //Parameter
    "para":{
    "Region":"California"
    },
    "target":"_dialog",    //Open as a dialog
    "feature":{
    "width":700,
    "height":500,
    "title":"Region Sales Situation"
    }
    })
    Application

    Click the button to open a dialog with the title "Region Sales Situation", width 700, height 500, where the content of the dialog box is the sales data of California.

    Click to download the template.

    Use POST to open a dialog box.fvs

    Screen Recording 2023-07-31 at 17.42.17.gif

    Mobile terminal

    Not supported

    doURLPrint

    iconNote:
    FVS templates do not support doURLPrint.


    Method

    doURLPrint(config)

    Call up the printing tool to print reports

    Parameter

    config: object

    config: Print parameter. For details about the parameter format, see doURLPrint.

    Returned value

    void

    Example

    See: doURLPrint.

    Application

    Customize the print button to print reports using "Zero Client Printing".

    6.gif

    Mobile terminal

    Not supported

    Msg

    Method

    Msg

    FineReport has built-in a message box with a unified style that can replace the alert, confirm, prompt, and toast pop-up boxes in Windows.

    Parameter

    config: object

    It shall be used together with other methods. For details, see Msg.

    Returned value

    void

    Example

    See: Msg.

    Application

    See: Msg.

    Mobile terminal

    Supported

    remoteEvaluate

    Method

    remoteEvaluate("formula")

    To execute FR built-in formulas to get the calculation result.

    iconNote:

    1. The remoteEvaluate(String) interface does not support tablename.select function.

    2. The remoteEvaluate(String) interface is not supported by web pages.


    Parameter

    formula: String

    Formula

    Returned value

    object

    Example

    Call the sum function in FineReport for general reports and dashboards to sum A1 and A2.

    FR.remoteEvaluate("sum(A1,A2)");

    Call the CONCATENATE function in FineReport to link strings together for general reports and dashboards.

    FR.remoteEvaluate('CONCATENATE("001","1201110")');

    For FVS templates (V1.15.0 and later versions are supported):

    duchamp.remoteEvaluate("sum(A1,A2)");
    Application

    -

    Mobile terminal

    Supported

    iconNote:
    Starting from version 9.0, the mobile App no longer supports FR.remoteEvaluate(formula), and it will report an error saying "synchronous http requests are not supported".


    Notes:

    The use of the remoteEvaluate interface may allow attackers to perform operations on the database such as adding, deleting, modifying, and querying, posing a security risk that is equivalent to allowing remote execution.

    Therefore, a Forbid Script to Call Formula function has been added to the decision-making platform and is enabled by default. If you use the remoteEvaluate interface and enable this function, a prompt message will pop up during the preview saying "This call has security risks. If you need to use it, please modify the script call formula restrictions in Security Management", as shown below.

    Xnip2023-07-31_18-02-03.jpg

    If you do not want this popup message, you need to disable the function in the platform. For details, see Security Protection Settings.

    jsonEncode

    Method

    jsonEncode(code)

    Encode the string using jsonEncode

    Parameter

    code:String

    String to be encoded, required

    Returned value

    String

    Example

    Encode the report path using jsonEncode.

    For general reports and dashboards:

    FR.jsonEncode("/webroot/decision/view/report?viewlet=GettingStarted.cpt");

    For FVS templates:

    duchamp.jsonEncode("/webroot/decision/view/report?viewlet=GettingStarted.cpt");
    Application

    -

    Mobile terminal

    Not supported

    jsonDecode

    Method

    jsonDecode(jsonEncode)

    Decode a string that has been encoded using jsonEncode

    Parameter

    code:String

    String to be encoded, required

    Returned value

    String

    Example

    Decode the report path that has been encoded using jsonEncode.

    For general reports and dashboards:

    FR.jsonDecode(FR.jsonEncode(
    "/webroot/decision/view/report?viewlet=GettingStarted.cpt");

    For FVS templates:

    duchamp.jsonDecode(duchamp.jsonEncode(
    "/webroot/decision/view/report?viewlet=GettingStarted.cpt");
    Application

    -

    Mobile terminal

    Not supported

    ajax

    Method

    ajax(options)

    It is the jQuery.ajax() function after encapsulation, in which the data parameter is processed with Chinese, Japanese, and Korean encoding and can be called in any place where JS can be used through FR.ajax(options).

    Parameter

    options

    Ajax parameter in JSON format, see ajax.

    Returned value

    void

    Example

    See ajax.

    Application

    See ajax.

    Mobile terminal

    Supported

    isEmpty

    Method

    isEmpty(object)

    Check if the object is empty.

    Parameter

    Object:Object

    Object

    Returned value

    Boolean

    Whether it is empty or not.

    true: Yes

    false: No

    Example

    1) Check if the string control named text0 exists.

    For general reports and dashboards (widgets in the parameter panel):

    var a = FR.isEmpty(_g().getParameterContainer().getWidgetByName("text0"));
    alert(a);

    For FVS templates:

    var a = duchamp.isEmpty(duchamp.getWidgetByName("text0"));
    alert(a);

    2) Check if the string control named text0 is empty.

    For general reports and dashboards (widgets in the parameter panel):

    var a = FR.isEmpty(_g().getParameterContainer().getWidgetByName("text0").getValue());
    alert(a);

    For FVS templates:

    var a = duchamp.isEmpty(duchamp.getWidgetByName("text0").getValue());
    alert(a);
    Application

    -

    Mobile terminal

    Not supported

    isArray

    Method

    isArray(object)

    Check if the object is an array

    Parameter

    Object:Object

    Object

    Returned value

    Boolean

    Whether it is empty or not.

    true: Yes

    false: No

    Example

    Define an array and check if it is an array.

    For general reports and dashboards:

    var txt = new Array("I","love","FR");
    FR.isArray(txt);

    For FVS templates:

    var txt = new Array("I","love","FR");
    alert(duchamp.isArray(txt));
    Application

    -

    Mobile terminal

    Not supported

    cellStr2ColumnRow

    Method

    cellStr2ColumnRow(cell)

    Get row and column indexes based on the cell number

    Parameter

    cell

    Cell number

    Returned value

    {col:colindex, row:rowindex}

    Row and column indexes in JSON format

    col: Column index, starting from 0

    row: Row index, starting from 0

    Example

    Example 1: Return the row and column information of cell A1 in general reports or dashboards.

    FR.cellStr2ColumnRow("A1");

    Example 2: Print the row number of cell A1 in general reports or dashboards.

    var a=FR.cellStr2ColumnRow("A1").row+1;
    FR.Msg.alert("Prompt", "The row number of cell A1 is"+a);

    Example 3: Print the row and column number of a cell in FVS templates.

    v

    ar a=duchamp.cellStr2ColumnRow("A3").col+1;
    var b=duchamp.cellStr2ColumnRow("A3").row+1;
    //alert(a);
    duchamp.Msg.alert({
    title: "Prompt",
    message:  "The column number of cell A3 is"+a,
    });
    duchamp.Msg.alert({
    title: "Prompt",
    message:  "The row number of cell A3 is"+b,
    });
    Application

    For general reports: 

    Click the button to print the row number of cell A1.

    8.gif

    For FVS templates: 

    Click the button to print the row and column number of cell A3.

    Click to download the template. 

    Print cell row and column information.fvs

    Screen Recording 2023-07-31 at 17.46.14.gif

    Mobile terminal

    Supported

    columnRow2CellStr

    Method

    columnRow2CellStr({col:colindex, row: rowindex})

    Get cell number based on row and column number

    Parameter

    {col:colindex, row:rowindex}

    Row and column indexes in JSON format

    Returned value

    cell

    Cell number

    Example

    Example 1: Get the cell number of the cell in general reports or dashboards with row index 3 and column index 1.

    FR.columnRow2CellStr({col:1, row:3});

    Example 2: Print the cell number of the cell in general reports or dashboards with row index 3 and column index 1.

    var a=FR.columnRow2CellStr({col:1, row:3})
    FR.Msg.alert("Prompt", "The cell number of the cell with row index 3 and column index 1 is "+a);

    Example 3: Print the cell number of the cell in FVS templates with row index 3 and column index 1.

    var a=duchamp.columnRow2CellStr({col:1, row:3})
    duchamp.Msg.alert({
    title: "Prompt",
    message: "Row index 3, column index 1 cell number"+a,
    });
    Application

    For general reports: Row index 3, column index 1 cell number is B4

    9.gif

    For FVS templates: Print a cell number whose row index is 3 and column index is 1.

    Click to download the template. 

    Get cell number with column number.fvs

    Screen Recording 2023-07-31 at 17.46.49.gif

    Mobile terminal

    Not supported

    Attachment List


    Theme: Secondary Development
    • 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