How To : Hide/Show Fields in Zoho Creator

Feb 03 2009 02:16:30 AM Posted By : Latha
Comments (3)

A simple but oft repeated query in Zoho Creator Help/Forums is how to dynamically hide and show fields in ZC forms. In this blog, we present how-to-do tips on using the Hide/Show functionality to create smart forms that hide irrelevant information from the user or adjust as the user is entering information.

1. Show fields only to the application owner

Assume you are the HR manager and you have created the following "Job Application" Form to enable applicants to apply for vacancies in your organization. In this form, the field Call for Written Test will be used only by the app owner (HR manager) to decide if the candidate must be called for an interview, and should not be displayed to users.



To make the Call for Written Test field accessible only to the application owner, select the check-box option Hide this field to others, from the Edit Options for this field and click Done to update the changes, as shown below:



Now, the field will be displayed in the form only if the login user is the application owner. Shared users will not be able to view this field. The form will be displayed to users as shown below:




2. Conditionally Hide/Show fields


You can also conditionally show/hide specific fields in your form by adding a bit of Deluge Scripting. For example, if the user chooses "Option1" on a drop-down field, show certain fields else show some other fields.

The Hide <fieldname> Deluge task can be used to dynamically hide specific fields, when not required. The field will not be available for viewing/editing to both the owner of the application and to people with whom you are sharing the application.

The Show <fieldname>Deluge task is used to display a field that was previously hidden.

Here are a few sample scenarios:

a. Hide/Show fields based on value selected in another field

- In the "Sample1" form given below, the text-field "ResearchQuestion" is hidden when the form is loaded. It will be displayed only if the value of the field "Type" is selected as "Research".

To achieve this,

- Select Form Actions ->  On Add -> On Load block in Script builder. The on Add -> on Load script is executed when the form is loaded to add a new record.

- Add the Deluge task hide ResearchQuestion, as shown in the screen-shot below and click Save  Script to update the changes.

(You can drag-n-drop each task to the editor area and use the Edit button to configure field names, variables and expressions using the Deluge Expression builder)


To display the field ResearchQuestion only if the Type is selected as "Research",

- Select Field Actions -> Type -> On User input block in Script builder. The Field Actions -> on user input script is executed when the Type field value is changed.

- Add the If condition and statements to display the field only if the Type field is selected as "Research", as shown below. Click Save  Script to update the changes.

zoho creator script editor

The ResearchQuestion field is displayed if Type is selected as "Research", as shown below.


b. Hide/Show fields based on login user

Sometimes you may want to restrict access to certain users only to specific fields in your form. This can be achieved using the Deluge variable zoho.loginuser, which returns the name of the login user and the  Hide <fieldname> deluge task, within a If condition.

For example, assume you want to restrict edit access to the Name and E-mail field only to the HR Manager, whose login user name is "HRAdmin". 

To achieve this,

- Select Form Actions ->  On Edit -> On Load block in Script builder. The on Edit -> on Load script is executed when the form is loaded to edit an existing record.

- Add the If condition to check for the login user name and the If statements to be executed . The If statements will be executed if the login user name is not "HRAdmin". (i.e) the Name and E-mail field will not be displayed for editing, if the loginuserid is not "HRAdmin".

- Click Save  Script to update the changes.

(You can drag-n-drop each task to the editor area and use the Edit button to configure field names, variables and expressions using the Deluge Expression builder)




Related Help Links:

Help Doc - Deluge Script -> Hide/Show
Help Doc - Deluge Script -> Using Script Builder

Related Forum Discussions:
 
http://discussions.zoho.com/zohoforums?ftid=2266000000150851
http://discussions.zoho.com/zohoforums?ftid=2266000000138102
http://discussions.zoho.com/zohoforums?ftid=2266000000018120
Comments

Post Comment