A record is a row of data submitted through a Form. In the topic,"Form Types" we have learnt that Zoho Creator supports two types of Forms - Normal Forms and Stateless Forms. The data submitted through a Normal Form will be directly added to the relevant table in your database.
Who can add records?
- Application Owner.
- Shared users with access permission to add the records.
- In the screen-shot given below, a Sales record is entered in the Sales Form. On click of the Submit button, the Sales data will be updated in the Sales database. If Form action scripts are configured to validate data, the data will be updated only if validation is successful.
- You can also add records to the Form by clicking the Add button in the report header, as shown in the screen-shot below. For shared users, the Add button will be displayed in a Report only if access permission is provided by the app owner, to add new records.
- Importing data is another way of adding records. For example, if you have Sales data stored in an excel file, you can directly transfer this data to your Sales database. You can import data in two ways:
1. Write/Paste Data from the XLS file.
2. Import Data from the XLS files by specifying the file name.
Refer the topic Import and Export Data for more information.
Zoho Creator automatically updates the Added time and the Added User's Name and IP address, for each record added to the database.
1. Restrict entries to a form by everyone except the admin user
In the following code, Added_User stores the name of the user who added the current record and zoho.adminuser returns the name of the admin user. If the added user name is not equal to the admin user name, the record will not be added. The code is added on add ->validate block of the Script tab.
alert "You are not authorized to add records";
Zoho Creator automatically tracks details about when and by whom a record was added or modified using the fields Added User, Added Time, Modified User and Modified Time. This information will be displayed in the view, if the columns are selected from Column Properties option of the View tab in Edit mode. Refer the topic, Display User name and time, for more information.
2. Restrict entries to my Registration Form based on a given date
Assume you have a Registration form to register for a specific course and the registration is open till 30th Dec 2009. To restrict entries from being submitted after this date, use the zoho.currentdate variable within the on add ->on validate block of the Script tab, to validate if the registration date has expired. The sample code is given below.
alert "time for registration expired";