Hide and Show

 Overview

The deluge Hide/Show keyword is used in On user input field action script and On load form action script to hide/show a form field. Introducing a script to hide a field disallows that field from being visible to the shared users as well as the owner or administrator of the application. The Show keyword enables you to make the hidden field visible in the form.

Note:

  • Hide/Show functions cannot be applied to Formula fields using Deluge.

 Syntax

hide <field name>;
show <field name>;

 Using Script Builder

To hide/show a field a form:

  1. Invoke the Script Builder.
  2. Select the required Form/Field action.
  3. Drag-n-drop the Hide/Show task from the left-side task tree. The Hide/Show pop-up appears.
  4. Select the function Hide to hide a field or Show to show a field which is already hidden.
  5. Select the required field from the Select Field Name dropdown.
  6. Click Done to add the script.

Refer the topic Using Script Builder for detailed steps to invoke the script builder and add the script.

 Examples

  1. The following code added to the On Add - On Load block of the Form will hide the fields named Activity2 and Activity3 when the form is loaded.

    hide Activity2;
    hide Activity3;

  2. The following code is added to the On User Input block of the field named activities and will be executed when this field value is changed. The fields that were previously hidden during form load will be displayed based on the value entered in this field.

    if (activities >= 2)
    {
    show Activity2;
    }
    else
    {
    hide Activity2;
    }
    if (activities >= 3)
    {
    show Activity3;
    }
     

  3. The following sample code is added to the On User input block of the Medical_Profession field. It will display the field named Medical_Profession_Type only when the Medical Professional checkbox field is selected. 

    if (input.Medical_Profession)
    {
    show Medical_Profession_Type;
    }
    else
    {
    hide Medical_Profession_Type;
    }
     

  4. The following script is added to the Form Actions - On add - On Load block of a Form. The script will be executed when the Form is loaded to add a record. It will hide the form fields when the form loads after 01-Jan-2007 and will display the message “Registration is CLOSED!”

    if (zoho.currenttime > ‘01-Jan-2007 00:00:00?)
    {
    hide name;
    hide emailid;
    hide blog_url;
    hide about_yourself;
    hide emailiderror;
    set showmessage = “Registration is CLOSED!”;
    }
     

     
  5. The following On edit ->On load script will restrict access to all your shared users to edit only specific fields in your form. The script will be executed when a form is loaded for editing. The "If" statements will be executed if the login user is not the admin user.
    on edit
    {
    on load
    {
    if (zoho.loginuser != zoho.adminuser)
    {
    hide Company;
    hide First_Name;
    hide Last_Name;
    hide Cell_Phone_Number;
    hide Email_Address;
    }
    }
    }
  6. The sample code given below will hide the field named “Name” if the currenttime is past 5.00 pm
    hr =zoho.currenttime.toString(“HH”).toLong();
    min =zoho.currenttime.toString(“mm”).toLong();
    sec = zoho.currenttime.toString(“ss”).toLong();
    If ( hr >= 17 &&min >0 &&sec >0)
    {
    hide input.Name;
    }