JS Get the Returned Value of Data Entry

  • Last update:  2020-12-16
  • I. Overview

    1.1 Requirement

    When performing data entry in a report, we often wish to know whether or not data entry succeeds. How can we get the returned value of data entry success/failure through JS?


    1.2 Solution

    There are three event types for widgets:

    1) JavaScript

    2) Commit to Database

    3) Send Email

    When Commit to Database is selected as the event type, set Callback Function to return some information.  The return parameter is fr_submitinfo and whether the value of fr_submitinfo.success is true or false can tell whether data entry is successful: if true, data entry succeeds, or it fails.

    Note

    The fr_submitinfo interface parameter applies to two scenarios: one is the above-mentioned “Callback events”, the other is “After Data Entry events”, which indicates that in an After Data Entry event, fr_submitinfo can be used to judge whether the background program is normally executed. 

    II. Sample

    2.1 Steps

    1) Create a blank template, add several text widgets to the template and then add a button widget to G2. The report body is set as follows:

     

    2) Add a Click event to the button widget, whose event type is Commit to Database, and then bind a database to the button, as shown in the figure below:

     

    3) Click the Set Callback Function button at the bottom of the dialog box to determine the next step according to whether data entry succeeds. If data entry succeeds, then a message “Submitted successfully” will appear; if it fails, then a message “Submission Failed” will appear

     

    Input the following JS codes:

    if (fr_submitinfo.success) {
           FR.Msg.toast('Submitted successfully');
    } else {
           FR.Msg.toast('Submission Failed');
    }

    Note

    Success only indicates normal background program execution, rather than successful data submission.

     4) Click Data Entry Preview, fill in the data on the Web and click the submit button. If the data is submitted successfully, a message “Submitted successfully” will appear; or a message “Submission Failed” will appear.


    2.2 Preview

    Save the template and click [Pagination Preview]. The effect on a PC is shown in the figure below:

      

    III. Download the template

    Attachment List


    Theme: Data Entry
    • 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