Examples of Calling Scheduled Task APIs in FineReport Templates

  • Last update: December 23, 2025
  • Overview

    This document demonstrates how to call scheduled task APIs in FineReport templates.

    Before reading this document, view the following two documents to learn more about API calls:

    iconNote:
    The solutions in this document do not apply to mobile devices.

    Example One: FineDataLink Standalone Deployment

    This document demonstrates how to call the Run a Task by Task ID API in a FineReport template.

    Preparing Plugins

    For details, see the "Plugin Introduction" section of Description of Calling APIs Related to Scheduled Tasks.

    Creating an Application in the FineDataLink Project

    1. Log in to the FineDataLink project, choose System Management > Open Platform > Application Management, and click Add. Name the application and set Alternative Authentication to AK/SK Direct Authentication, as shown in the following figure.

    iconNote:
    You are advised to use AK/SK Direct Authentication or Digest Signature Authentication if FineReport and FineDataLink projects are deployed independently.

    2. Click the  icon on the right side of the created application, and remember the values of Application ID and Secret Key, as shown in the following figure.

    Granting Permission on the New Application

    Choose Permission Management > Application. This step illustrates how to assign permission on the Run a Task by Task ID API for the new application, as shown in the following figure.

    Recording the ID of the Task to Be Called

    Locate the scheduled task to be called in Data Development. Copy and record the task ID, as shown in the following figure.

    iconNote:
    An instance ID is required to call the Query Instance Information by Instance ID API. For details about how to obtain the instance ID, see the "Introduction to Pages After Successful Plugin Installation" section of Description of Calling APIs Related to Scheduled Tasks.

    Configuring FineDataLink API Forwarding in FineReport

    Enter the decision-making platform of FineReport, choose System Management > System Setting > General, and configure FineDataLink API Forwarding.


    Setting ItemDescription
    Application ID in Open PlatformEnter the application ID, which is the value of Application ID in the "Creating an Application in the FineDataLink Project" section of this document.
    Application Secret Key in Open PlatformEnter the secret key of the application, which is the value of Secret Key in the "Creating an Application in the FineDataLink Project" section of this document.
    FineDataLink Address

    Enter the FineDataLink project address, for example, http://192.168.101.211:10636/webroot/decision.

    Calling the API in a FineReport Template

    Open the GettingStartedEN.cpt template in FineReport, add a button widget to the parameter panel, and add a click event to the button, as shown in the following figure.

    The JavaScript code is as follows:

    iconNote:
    Modify the workId value to the task ID you obtain in the "Recording the ID of the Task to Be Called" section of this document.
    FR.ExecuteWorkByWorkId(
        {
            workId: "5820487a-e86d-4412-8d48-312cc4dc0efc",
            params: {
                paramName: "paramValue",
            },
            waitForResponse: "true",
            waitTime: 10000,
        },
        function (error, response) {
            if (error) {
                console.error("Request failed:" + error);
            } else {
                console.log("The request was successful, and the response data is:" + JSON.stringify(response));
            }
        }
    );

    Effect Display

    Preview the template and click the button, as shown in the following figure.

    Choose O&M Center > Scheduled Task > Execution Record in the FineDataLink project. You can view the latest execution record of the called task, as shown in the following figure.

    Example Two: Calling an API to Execute a Scheduled Task with Parameters in a FineReport Template

    iconNote:
    This example uses a FineDataLink project deployed independently and uses the Run a Task by Task ID API.

    Objective: Pass the city and country selected from the drop-down list in the FineReport template as parameter values to a scheduled task to trigger its execution.

    Preparation

    See the above sections to prepare plugins, create an application in the FineDataLink project, grant permission on the new application, and configure FineDataLink API Forwarding in FineReport.

    Preparing the Scheduled Task and the FineReport Template

    1. There are two parameters, City and Country, in the scheduled task in FineDataLink, as shown in the following figure.

    You can set default values for the parameters to facilitate debugging.

    2. There are two drop-down box widgets, City and Country, in the parameter panel of the FineReport template, as shown in the following figure.

    Calling the API in the FineReport Template

    1. Record the task ID. For details, see the "Recording the ID of the Task to Be Called" section of this document.

    2. Add a button widget to the parameter panel of the FineReport template and add a click event to the button, as shown in the following figure.

    The JavaScript code is as follows:

    iconNote:
    Enter the parameter names in the FineReport template in the parentheses after getWidgetByName and alert. The content in params should be in the format of Name of the parameter in the scheduled taskName of the parameter to be passed from the FineReport template. The value of workId is the scheduled task ID, which can be obtained by referring to the "Recording the ID of the Task to Be Called" section of this document.
    var City=_g().getParameterContainer().getWidgetByName("City").getValue();
    alert(City);
    var Country=_g().getParameterContainer().getWidgetByName("Country").getValue();
    alert(Country);
    FR.ExecuteWorkByWorkId(
       {  
           workId: "be0e38e8-4ec9-40a5-a92e-5a6c660f2e9b",
           params: {
               City:City,
               Country:Country,
           },
           waitForResponse: "true",
           waitTime: 10000,
       },
       function (error, response) {
           if (error) {
               console.error("Request failed:" + error);
           } else {
               console.log("The request was successful and the response data is:" + JSON.stringify(response));
           }
       }
     
    );

    Effect Display

    1. Preview the template and click the button, as shown in the following figure.

    ScreenRecorderProject3_4.gif

    2. Choose O&M Center > Scheduled Task > Execution Record in the FineDataLink project. You can view the latest execution record of the called task. Data in the target table is shown in the following figure.

    附件列表


    主题: Data Development - Scheduled Task
    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