Creating Data Entry Forms in Zoho Creator for Zoho Reports

Creating Data Entry Forms in Zoho Creator for Zoho Reports

You can create a data entry forms in Zoho Creator that can save the data fed into the forms directly into Zoho Reports for reporting & analytics. This can be done by creating the required forms and mapping the fields in the Zoho Creator form with the corresponding columns in a Zoho Reports table.

Let's say you have Sales table in a database called StoreSales in your Zoho Reports account as shown below and you want to create a data entry Web Form to this table. To do this, follow the steps given below.

Login to Zoho Creator with the same login credentials that you use for Zoho Reports.

If you have already created an Application in Zoho Creator you can open the existing application. If not, create a new application by clicking the Create Application button available in the home page. You will have to provide a mandatory application name to proceed. You can learn more about Creating an Application from our help document.

  • Inorder to edit an existing Application you need to go to the Edit mode of the application by clicking on the 'Edit' icon beside the application name. 
  • To create a New form select Create New > Form. You can create a form from scratch, import a file or use an existing template to build your form.
  • In the New form window, Enter a form name and also select the section in which you would like to place the form when you access the application.
  • Select the option Data will be stored in the creator and click Create .
    By default, Zoho Creator will have a table generated in the server to store data submitted through the Form. To save the submitted data into a Zoho Reports table instead of in a Zoho Creator table, this option must be deselected.

Note:
  • Store Data in Creator option is not shown when you are creating a New application with blank Form. This option will only be shown when creating a New Form in an existing application. In this case, instead of using the first Blank form that you have created, create another form and follow the given instructions.

A new blank Form named Sales Form will be created and listed under the Forms Tab. Now, drag and drop the required field types, depending on the kind of data that the Form should collect, from the Fields box displayed on the left-side of your Form.

  • You can rename of the field, by clicking on the Field name label, from the field properties box as shown above. 
  • Click on the "+" button to add a button (rename it as Add to Zoho Reports database) and select 'Field Type' as 'Submit'
  • Once you have added/renamed all the required fields, click Access this application. The resulting Form should look similar to the one in the below snapshot.

On Click Script

After you create the Form, you have to write a simple Deluge script which executes on clicking the button. Deluge script is an online scripting language which enables you to add the required logic to the Form to perform an action.

On Click Script to Add Data:

To add data submitted via Form, as a new row into the table in your Zoho Reports account, we have to write a deluge with createRow() task.

Syntax<return value as map> = zoho.reports.createRow(<Database Name>,<Table Name>,<Data as map>);

  • <Database Name> is the name of the reporting database in Zoho Reports.
  • <Table Name> is the name of the table in the corresponding reporting database in Zoho Reports.
  • <Data as map> is the map variable that holds key, value pairs. The map key is the column name of the table in your Zoho Reports account and the map value is the field value submitted in the Zoho Creator Form.
  • <return value as map> is the map object containing response returned by Zoho Reports.

Let's continue with the above example to illustrate how to use createRow() task to add data. Once you have dropped the required fields and added Add to Zoho Reports Database button to the Sales Form,

  • Hover your mouse over Add to Zoho Reports Database button and select Action on Click option. This will invoke the script builder in the Script tab.
  • Switch to Free-flow Scripting mode by clicking on the option present at the right side top corner of the script editor
  • Write the following deluge script as shown below in script editor and click Save Script.

    creatingMap = map();
    creatingMap.put("Date", input.Date_field);
    creatingMap.put("Region", input.Region);
    creatingMap.put("Product Category", input.Product_Category);
    creatingMap.put("Product", input.Product);
    creatingMap.put("Customer Name", input.Customer_Name);
    creatingMap.put("Sales", input.Sales.toString());
    creatingMap.put("Cost", input.Cost.toString());
    mapResponse = zoho.reports.createRow("StoreSales", "Sales", creatingMap);

In the above deluge script,

  • creatingMap is the map variable that holds the column names (Date, Region, Product Category, Product, Customer Name, Sales and Cost) and their corresponding values submitted in the Sales Form.
  • mapResponse is the variable which holds the XML string returned by Zoho Reports as response on adding the row.

When a user enters data and clicks Add to Zoho Reports Database button in the Sales Form, the given deluge script executes and adds submitted data as a new row into the Sales table in your Zoho Reports account.

On Click Script to Update Data:

You can also use a Zoho Creator Form to update existing data of a table in your Zoho Reports account. To update a row in Zoho Reports using a Form created in Zoho Creator, we have to write a deluge script with task update data()
Syntax: <return value as map>= zoho.reports.updatedata(<Database Name>,<Table Name>, CreatingMap, <Criteria>);

  • <Database Name> is the name of the reporting database in Zoho Reports.
  • <Table Name> is the name of the table in the corresponding reporting database in Zoho Reports.
  • <Data as map> is the map variable that holds key, value pairs. The map key is the column name of the table in your Zoho Reports account and the map value is the field value submitted in the Zoho Creator Form.
  • <Criteria> must be in the format: {<colName> <operator> <colValue>}. For example ("Region"='East'). Refer here for more details about the format for the criteria.
  • <return value as map> is the map object containing response returned by Zoho Reports.

In the given example, to Update an existing row in the Sales table of the StoreSales Database in your Zoho Reports account with the submitted data via SalesForm,

  • Add a button (say, Update button) to the Sales Form 
  • Hover your mouse over the Update button and select Action on Click option will invoke the script builder in the Script tab.
  • Switch to Free-flow Scripting mode by clicking on the option present at the right side top corner of the script editor.
  • Write the following deluge script as shown below in script editor and click Save Script .

creatingMap = map();
creatingMap.put("Date", input.Date_field);
creatingMap.put("Region", input.Region);
creatingMap.put("Product Category", input.Product_Category);
creatingMap.put("Product", input.Product);
creatingMap.put("Customer Name", input.Customer_Name);
creatingMap.put("Sales", input.Sales.toString());
creatingMap.put("Cost", input.Cost.toString());
mapResponse = zoho.reports.updatedata("StoreSales", "Sales", creatingMap, "Region = 'East' and Sales =10000 ");

When a user enters data in to the Sales Form and clicks Update button, the given deluge script executes and all the rows of Sales table in StoreSales database with Region as 'East' and Sales of '10000' will be updated with the submitted data.

On Click Script to Delete a Row:

To delete a specific row of a table in your Zoho Reports, we have to write a deluge with deleterow() task.

Syntax : <return value as map> = zoho.reports.deleteRow(<Database Name>,<Table Name>, <Criteria>);

  • <Database Name> is the name of the reporting database in Zoho Reports.
  • <Table Name> is the name of the table in the corresponding reporting database in Zoho Reports .
  • <Criteria> must be in the format: {<colName> <operator> <colValue>}. For example ("Region"='East') . Refer here for more details about the format for the criteria.
  • <return value as map> is the map object containing response returned by Zoho Reports.

For example, to delete all the Sales data of the 'West' region from the Sales table of the StoreSales Database in your Zoho Reports account, deluge script as shown below should be written in the script builder.

s = zoho.reports.deleteRow("StoreSales", "Sales", "Region='West'");

Entering Data in the Form

To enter the data in the Form and add/update the entered data into the table in your Zoho Reports account, select Access this Application option at the top right. Enter the required data into corresponding fields and click the required button to add or update the record in the corresponding table in Zoho Reports.

Checking Data in Zoho Reports table

Once the Form is successfully submitted, data will be added as a new row to your Sales table of StoreSales database when you click Add to Zoho Reports Database button, as shown below.

Similarly, if a user clicks Update button, all the rows in the table of the Zoho Reports that matches the given criteria will be updated with the submitted data.