Customizing Prompts in the Callback Function by JS

  • Last update:December 21, 2025
  • Overview

    Description

    Add an event of the Submit to Database type for a widget so that data can be submitted to the database after you click or edit the widget. However, success or failure prompts are not returned by default after data submission by this method. If you want the system to return result prompts after data submission or execute some custom methods based on the success or failure of the submission, how should this be achieved?

    Implementation Method

    When you use the Submit to Database type event, you can set the next step after successful or failed submission for the system by configuring Set Callback Function, as shown in the following figure.

    1.2 实现思路.png

    API Description

    The callback function returns the parameter fr_submitinfo for the system to determine whether the submission is successful. The return value of fr_submitinfo.success being true indicates successful submission, while false indicates failed submission. When the submission fails, fr_submitinfo.failinfo returns specific error information.

    Example

    The following example demonstrates how to use the returned values of the callback function to return receipt messages upon both successful and failed submission, and how to use a custom button to submit data.

    Report Style Design

    Create a template, and design the report style as shown in the following figure. Add text widgets to cells A3 to F3, and add a button widget to cell G2.

    2.1 设计报表样式.png

    Submission Attribute Setting

    Click the button widget in cell G2, add a click event of the Submit to Database type for the button widget, bind the data columns to the cells, and set the submission attributes, as shown in the following figure.

    2.2 设置填报属性.png

    Callback Function Setting

    After setting the submission attributes, click Set Callback Function, add a JavaScript (JS) event, and set the event content to display "Successful Submission." if the submission is successful and "Failed Submission." if the submission fails, as shown in the following figure.

    2.3 设置回调函数.png

    The JS code is as follows.

    if (fr_submitinfo.success) {
    FR.Msg.toast('Successful Submission.');
    } else {
    FR.Msg.toast('Failed Submission. Error Message: ' + fr_submitinfo.failinfo);
    }

    iconNote:
    The prompt upon successful submission only indicates that the backend program is executed without any exceptions. The final submission result may be affected by the settings and may not be the same as expected.

    Effect Preview

    Save the template, click Data Entry Preview, enter data on the report page, and click the Submit button. If the submission is successful, the system will prompt "Successful Submission."; otherwise, it will prompt "Failed Submission.".

    iconNote:
    The effect cannot be previewed on mobile terminals.

    预览效果1成功.png

    预览效果2.png

    Template Download

    Download the template by clicking Customizing Prompts in the Callback Function by JS.cpt.

    Attachment List


    Theme: Data Entry
    Already the First
    Already the Last
    • 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