Error handling in forms | Zoho Creator Academy

Handle the error when an incorrect value is inputted by user

Requirement

Handle errors that occur when user enters an incorrect value. 

Use case

A company uses Zoho Recruit to maintain interview and candidate details. To let their candidates know their status, the company uses a Zoho Creator form. The candidates can enter their IDs and view their statuses. Also, the error that occurs when a candidate enters an incorrect ID is handled and a custom message is displayed. 

See how it works

Steps to follow

In this tutorial, the Candidate Status Without Error Handling form was created only for demonstration purpose. You may refrain from creating this form and skip steps 10 and 11 if needed.

1. Create a form with the following details.

Form

Form Link Name

Field Type

Field Name

Field Link Name

Candidate Status

Candidate_Status

 

Single Line

Candidate ID

 

Candidate_ID

Single Line

Status

Status


Let’s now create 2 identical forms to demonstrate how the use case works with and without error handling.

2. Create two stateless forms by duplicating the Candidate Status form and name them as Candidate Status With Error Handling and Candidate Status Without Error Handling.
Note: Stateless form’s field values cannot be accessed on submit of the form since data will not be stored in Zoho Creator. Therefore in this tutorial, the status will be fetched from Zoho Creator on user input of Candidate ID field. 
Let’s now remove the default buttons since they are not required for our use case.

3. Navigate to Form Properties and delete the Submit and Reset buttons from both the stateless forms. 



Disable the Status field of Candidate Status - With Error Handling form so it cannot be modified by the candidates.

4. Create a workflow with the following details.



5. In the Deluge editor, save the following script to disable the Status field.
  1. disable Status;
Disable the Status field of the Candidate Status - Without Error Handling form so it cannot be modified by the candidates.

6. Create a workflow with the following details.



7. In the Deluge editor, save the following script to disable the Status field.
  1. disable Status;
8. Create a connection with the following details. This connection will be used in step 10 and 12 to fetch candidate data from Zoho Recruit.



9. Now create another workflow with the following details to populate the Status field with values fetched from Zoho Recruit. This workflow includes error handling.



10. In the Deluge editor, save the following script to fetch data from Zoho Recruit based on the supplied record ID. The code is written within a try catch block to display a custom message if an error occurs.
  1. try 
  2. {
  3. // Fetches record from Zoho Recruit based on the record ID
  4. res = invokeurl
  5. [
  6. url :"https://recruit.zoho.com/recruit/v2/Candidates/" + input.Candidate_ID
  7. type :GET
  8. connection:"recruit_oauth_connection"
  9. ];
  10. // Extracts status from the fetched record
  11. input.Status = res.get("data").get(0).get("Candidate_Status");
  12. }
  13. catch (e)
  14. {
  15. // Displays a custom alert if an incorrect candidate ID is supplied
  16. alert "The entered candidate ID seems to be incorrect. Please verify. For further queries, reach us at support@zylker.com.";
  17. }
Note: Steps 10 and 11 are the repetition of steps 8 and 9 but without error handling. This is included in this tutorial to demonstrate how the use case works if error handling is not implemented.
11.  Create another workflow with the following details to populate the Status field with values fetched from Zoho Recruit. This workflow doesn't include error handling.

 

12. In the Deluge editor, save the following script to fetch data from Zoho Recruit based on the record ID supplied. 
  1. res = invokeurl
  2. [
  3. url :"https://recruit.zoho.com/recruit/v2/Candidates/" + input.Candidate_ID
  4. type :GET
  5. connection:"recruit_oauth_connection"
  6. ];
  7. input.Status = res.get("data").get(0).get("Candidate_Status");
13. Publish the Candidate Status With Error Handling form and share the permalink with the candidates. This allows the candidates to access the form without a Zoho Creator account.

See how it works 



  1. Zoho Recruit API 
  2. Duplicate a form
  3. InvokeUrl task
  4. Alert task
  5. Publish a form