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.

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.

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.

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.

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);
}
Note: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.".
Note:

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