This guide will help you with the following:
1. Hide | Show
2. Enable | Disable
3. Add | Append
4. Select | Deselect
5. SelectAll | DeselectAll
6. Clear items
7. Alert
8. Reload
1. Hide | Show
Overview
The hide deluge task hides a specified field on a form.
The show deluge task reverses the hide action and unhides the hidden field in the form.
Note:
To hide or show a field in a report, navigate to column properties in a Report, select the required field and click on the delete icon.
To hide fields for a set of users, you can define field permissions.
Syntax
To hide a field
To unhide a field
This task can be used in the following events
Example
The following snippet hides the "Phone Number" field if the selected contact mode is "Email".
- if(Contact_Mode=="Email")
- {
- hide Phone_Number;
- }
- else
- {
- show Phone_Number;
- }
2. Enable | Disable
Overview
The Disable deluge task disables a specified field on the form. The disabled field will be grayed out, and the user will not be able to add data to that field.
The Enable deluge task reverses the Disable action and re-enables a disabled field for users to fill it out in the form.
Note:
To disable fields for a set of users, you can define field permissions.
Syntax
To disable a field
- disable <field_link_name>;
To enable a field
- enable <field_link_name>;
This task can be used in the following events
Example
The following snippet disables the "Total Amount" field.
3. Add | Append
Overview
The Add deluge task replaces all the existing choices in a single-select, multi-select field or a lookup field type with specified choices.
The Append deluge task appends specified choices to the existing choices in a single-select, multi-select or a lookup field type.
Note:
- Only the first add command in each script action will remove the previous choices
- The same choice cannot be added or appended twice
- It is advisable to use the clear task before using the add task, to make sure the choices are cleared before the new choices are added.
Syntax
To add items
- <field_link_name>:ui.add(<expression>);
To append items
- <field_link_name>:ui.append(<expression>);
This task can be used in the following events
Examples
1) In the following example, "colors" is a form field of drop-down type. "Get_Bright_Colors" is a decision-box field type, which when checked, adds one set of colors to the "colors" field and adds another set if unchecked.
- if(Get_Bright_Colors)
- {
- addColors={"white","orange","yellow"}
- }
- else
- {
- addColors={"Brown","Black","Grey"};
- }
- clear colors;
- colors:ui.add(addColors);
2) If "product" is drop-down field with options "Zoho CRM", "Zoho Creator" and "Zoho Desk", the following script appends "Zoho Cliq" to the options. The "product" field will then have "Zoho CRM", "Zoho Creator", "Zoho Desk" and "Zoho Cliq" as the choices.
- product:ui.append("Zoho Cliq");
4. Select | Deselect
Overview
The Select deluge task selects a specified choice in a single-select, multi-select or a lookup field.
The Deselect deluge task deselects a specified choice(previously selected) in a single-select, multi-select or a lookup field.
Note:
If a choice is selected using the assignment operator '=', and another choice is selected using the select task, the assignment operator will overwrite the select task.
Syntax
To select a choice
- <field_link_name>.select(<expression>);
To deselect a selected choice
- <field_link_name>.deselect(<expression>);
This task can be used in the following events
Example
In the following example, if no color has been selected from the options in "Color selection" field, the option "White" gets selected automatically.
- if(Color_selection ==null)
- {
- Color_selection.select("White");
- }
5. SelectAll | DeselectAll
Overview
The selectAll deluge task preselects all choices in a specified multi-select or a lookup field(multi select or checkbox display).
The deselectAll deluge task deselects all choices(previously selected) in a specified multi-select or a lookup field(multi select or checkbox display).
Syntax
To select all choices
- <field_link_name>.selectAll;
To deselect all selected choices
- <field_link_name>.deselectAll;
This task can be used in the following events
Examples
1) In the following example, if the "Register all" decision box is checked, all the choices(games) present in the "Games" multi-select field will be selected.
- if(Register_all)
- {
- Games.selectall();
- }
2) In the following example, if the "Reset selection" decision box is checked, all the choices(games) present in the "Games" multi-select field will be deselected.
- if(Reset_selection)
- {
- Games.deselectall();
- }
6. Clear items
Overview
The clear items deluge task clears(removes) all choices in a specified single-select, multi-select or lookup field.
This task only hides the choices from appearing, and does not delete them from the database.
Note:
It is advisable to use the clear task before using the add task, to make sure the choices are cleared before the new choices are added.
Syntax
This task can be used in the following events
Example
In the following example, "colors" is a form field of drop-down type. "Get_Bright_Colors" is a decision-box field type, which when checked, adds one set of colors to the "colors" field and adds another set if unchecked. Before adding the choices, the clear task makes sure the previous choices have been removed.
- if(Get_Bright_Colors)
- {
- addColors={"white","orange","yellow"}
- }
- else
- {
- addColors={"Brown","Black","Grey"};
- }
- clear colors;
- colors:ui.add(addColors);
7. Alert
Overview
The Alert Deluge task displays a specified message in a pop-up window or below the specified field to the user.
This task will be listed under Client Functions in all events except the "On Validate" event in which it will be listed under Debug.
Note:
- The collective response from the info and alert statements in a function can be up to 500 KB. When this is limit is exceeded, the response will be truncated and appended with the following note:
- The info message has been truncated because its size exceeded 500 KB.
- The alert task will be executed in the On Validate event only when followed by the cancel submit task or the cancel delete task.
- The info task differs from the alert statement in the following ways:
- The info statement can be used in all workflow events.
- A user must be an admin to be able to view the output of the info statement.
- When the info statement is executed in On load, On validate, On success, On user input, Subform on add row, and Subform on delete row events, the output of the info statement can be viewed only by clicking on "View Log Details" button at the bottom of the form.
Syntax
(or)
- alert([<field_link_name>], <message>);
This task can be used in the following events
Example 1: Standard alert
In the following example, if the Age field has a value lesser than 18, the user is shown an alert message and the form submission is canceled. This alert message will be displayed in a pop-up window.
- if(Age < 18)
- {
- alert"You are not authorized to make this transaction";
- cancel submit;
- }
where:
"You are not authorized to make this transaction": The TEXT that represents the custom error message that needs to be displayed in a pop-up window.
Example 2: Inline alert
The following example displays a custom error message below the specified date field - due_date.
- if(due_date < zoho.currentdate)
- {
- alert(due_date, "Enter a future date");
- cancel submit;
- }
where:
due_date: The FIELD that represents the field link name.
"Enter a future date": The TEXT that represents the custom error message.
8. Reload
Overview
The Reload deluge task reloads the form.
Note: When a form is reloaded, its unsubmitted field entries (if any) will be lost.
Syntax
This task can be used in the following events