I. Overview
1) When creating a data entry report, the most important step is to bind the stored values to the fields in the database table, and control it by setting the [Template] > [Data Entry Attributes].
2) The most common way to bind a value to a field is to bind the cell through built-in SQL. At this time, similar to Excel, you can add cells intelligently; in addition to the bound cell, the value of the data column can also be a constant, formula, parameter, etc.
3) Another method is to implement custom submission through custom events, which are introduced separately below.
| You will learn |
|---|
|
II. Introduction to Data Entry Attributes
1. The setup interface
There are three data entry attributes: Submit, Data Validation and Data Entry Shortcut key setting.

2. Submit-Submit Type

1) Smart Submit: The backend will automatically execute inserting, updating and/or deleting. If two or three submit types are needed, you can choose Smart Submit. When using Smart Submit, it will diagnose if there is a key. If there is a key, Update Submit will be enabled, and if there is no key, Insert Submit will be enabled. But the data entry efficiency will be lowered. For this reason, if only one submit type is needed, choose the desired one. If there is a [Delete Row] button, Delete Submit will be enabled when using Smart Submit (click Delete Row and then click Submit). If several blank rows are inserted without editing, FineReport will recognize the values of these records as null, and blank records will not be stored to the database.
2) Insert Submit: If you only need to execute Insert Submit, generally, a blank table will be inserted. If Insert Submit is performed on the file displaying original data, original records will be reinserted to the database, so that data may be duplicated; if the key (the DB key instead of the report key) is defined in the DB table, when you choose Insert Submit, it may fail to submit because of index conflict.
3) Update Submit: Update all the existing data, so original data will be displayed in files, and you are required to check a column as the key.
4) Delete Submit: Delete all the existing data, so original data will be displayed in files, and you are required to check a column as the key.
3. Submit- Add Field and steps to bind cells
1) Choose a table, click [Smart Add Fields] and all the fields in the database will be automatically recognized. If you do not want to add all fields, uncheck the corresponding box.

2) Click [Add Field] to add a single field.

3) Once the field is added, click [Smart Add Cells] or [Smart Add Cell Group] to bind cells.

4) Smart Add Cell Group refers to bind multiple cells to one column, and enter all the data of these cells into the field. You can not only bind cells to columns, but also enter character strings, formulas, parameters and other types of data. If you double click the cell where the value is in the setup interface of Data Entry Attributes, the value designer will pop up.

5) If you insert a row or a column in the file and consequently data entry cells are offset by one cell, you can choose Batch Modify Cells.

6) Select a field, click [Remove Field], and the field will be deleted from the list.

7) The key: It is used to recognize if the value of the cell is the same as that in the database. If they are the same, update the value. If not, insert a value.

4. Submit-Submission Conditions
The built-in SQL allows data filtering in data entry. If the data sent by the Web end satisfy the submission conditions, the data will be loaded. If not, they will not be loaded.

1) Click [Submit Condition]
2) Select the Type of Common Condition
3) Select specific conditions
4) Select the correlation between the conditions: AND/OR
5) Select Add or Modify

5. Submit-Set Submit Event
A Submit Event is triggered once a SQL statement is executed, namely, once a record is submitted.
If the setup interface of Submit Event is consistent with that of Data Entry Attributes, it indicates that the setting of Submit Event is consistent with that of Data Entry Attributes.

6. Data Validation--Built-in Verify
You can add verification rules on the right side of the setup interface to normalize the data entry.

7. Data Validation—Custom Verify
Upon the completion of data entry in the Web page and before submission, if some special business logics are too complicated to be verified with the existing validation formula in FineReport, or if the user has a set of validation standard and wants to do data validation with his own program which will return the verification results to FineReport, Custom Verify is applicable in this case.

8. Data Entry Shortcut key setting
Click the switching icon to switch shortcut key bindings.

III. Examples of Data Entry Attributes
1. Open a CPT file
1) Open \demo\Data Entry\Basic Data Entry.cpt

2) Data Entry Preview

3) Open the setup interface of Data Entry Attributes

2. Built-in SQL
Basic steps are as follows:

1) Add a built-in SQL

2) Choose the Submit Type. The default is Smart Submit. Select the database table [EMPLOYEE] to be modified, and select Smart Add Fields.

3) Smart cell binding

4) Remove the [Salary] field

5) Select Submit Condition (optional)
6) Set Submit Event (optional)
3. Custom Submit
Basic steps are as follows:

1) Add Custom Submit
2) Choose the Submit Type
3) Select the corresponding class file
4) Bind cells or formulas to the variables defined in the class

4. Data Validation
1) Add built-in validation: the validation formula is INARRAY(C3,ds1.group(EMPID))=0, which means the input data should meet the validation formula, namely, the input data are not included in group(EMPID), otherwise an error message may prompt: "Employee ID already exists".
INARRAY() returns a Boolean value

2) Check the existing database tables

3) Preview the effect in the data entry interface. Enter the employee ID“1001”in the [No.] bar. Click data validation and it prompts that the employee ID already exists.

5. Data Validation-Custom Verify
This function enables you to verify, with Java class, if the data entered meet verification rules, and then to get the returned value.
1) Custom verification class allows record verification through the interface class com.fr.data.VerifyJob.class, and will locate to the error cell when the verification fails. It also allows page data verification through the interface class com.fr.data.VerifyJob.class.
2) Note: Whichever interface class is inherited, you should define a private variant “type”(or in any name you want) to return the verification results. If type=0, it indicates the verification succeeds. If type=1, it indicates the verification fails. The default is type=0.