Many a times, when you are developing an application, you may need to get the value(s) entered for the fields in the form. To get the particular value, you can do so in Deluge Script, using the statement:

input.<Field Name>

For ex, if you would like to obtain the value entered for the field with Field Name “Age”, you can to write 


For Multi-select and Checkbox fields, the above statement will return a collection and you’d need to iterate the collection and get each one of the selected values. You can use for each element task under List manipulation in the Script Builder for the same.

for each <elementname>  in <listname>
// write your code here

For ex, if you would like to get the values selected for a multi-select field with Field Name “Hobbies”, you need to write

for each selectedValue in input.Hobbies

A Note field is used to display text or images that guide the user while filling the form. This field will not be displayed in the View. You can display custom error messages in the Note field based on user input, using Deluge Scripting. The sample application Update Note  demonstrates how to display customized text in a Note field, based on user input to your form.. The script modifies the content of a Note field when a client-side event happens.

The application comprises of a form named Test form with the following fields:

  1. Fruit of type picklist to display the types of fruits.
  2. Flash monkey of type decision check box.
  3. note_buffer of type multi-line text to store the html image code, based on the selected fruit.
  4. the_note of type note to display the image of the selected fruit.

Adding Deluge Script

1. When the form is loaded, the on add -> on load script hides the note_buffer field, using the hide syntax.

on  add
on load
hide note_buffer;


2. The on user input script added in the Fruit field updates the note_buffer with a blob of HTML as a multiline string, based on the Fruitselected. This is then displayed in the the_note field.

type = picklist
values = {"apple", "banana", "cantelope"}
on user input
if (input.Fruit == "apple")
input.note_buffer = "<img height='250' width='250' src='http://images.jupiterimages.com/common/detail/39/61/23036139.jpg'/>";
else if (input.Fruit == "banana")
input.note_buffer = "<img height='250' width='250' src='http://www.momadvice.com/blog/uploaded_images/banana-759611.jpg'/>";
else if (input.Fruit == "cantelope")
input.note_buffer = "<img height='250' width='250' src='http://www.kids-cooking-activities.com/images/cantelope.jpg'/>";
input.the_note = input.note_buffer;


Code Explanation

if (input.Fruit == “apple”) – If condition to check the Fruit type

input.note_buffer = “<img height=’250′ width=’250′ src=’http://images.jupiterimages.com/common/detail/39/61/23036139.jpg’/>”; – Stores the html code as a multi-line string in the note_buffer field.

input.the_note = input.note_buffer; – Updates the_note field with the value stored in the above note_buffer field. This field displays the actual image.

3. If the show_monkey checkbox is selected, the on user input script added in the show_monkey field updates the note field with the fruit type and the monkey image, else only the fruit type is displayed.

displayname = "Flash monkey?"
type = checkbox
defaultvalue = false
on user input
if (input.show_monkey)
input.the_note = input.note_buffer + "<img height='250' width='250' src='http://upload.wikimedia.org/wikipedia/commons/2/27/Baby_ginger_monkey.jpg' />";
input.show_monkey = false;
input.the_note = input.note_buffer;

To convert the date format from “DD-MMM-YYYY” to “YYYY-MM-DD”, change the string with first format to date. Then convert that date object to a string specifying the second format. The below is the sample function which converts the format of the date to “YYYY-MM-DD” and return it as a string. Please refer to it. 

  1. string changedateformat(string inputdate) //input date is string in format “DD-MMM-YYYY”. for eg. 10-Sep-2010.
  2. {
  3.     dt = input.inputdate.toDate(“dd-MMM-yyyy”); // converting input string to date object specifying its format.
  4.     dt1 = dt.toString(“yyyy-MM-dd”);   // Now we convert the date object to string with our required format.
  5.     return dt1;   // returning the string object.
  6. }

The method of filtering a multi-select field is very similar to dynamically filtering single-select dropdowns as described here. However, the problem with filtering a multiselect is that when you edit the record the filtered list is not shown and all the checkbox options given in edit mode are listed instead. Filtering it again causes the selected options for the record to be lost. The workaround is to add a script in the on Edit>on Load task that saves the selected options, filters the list and sets the selection back again.

1. Create the multiselect with dummy options, note that when selections are saved in the field those options will be saved automatically
2. Setup dynamic filtering in the same way as for dropdown fields
3. In the on Add>on Edit action of the form write the following code:

      //first save the checked options in the Course field
      x = List();
      for each opt in input.Courses

      //clear it and filter it so that it shows the correct courses for the selected School
      clear Courses;
      rec  =  CourseForm [Criteria == input.School];

      //set the previously selected options again
      for each y in x

Deluge field names are often used in the following places.
  1. In the script
  2. To set values for the form field via URL
  3. To filter records from the View via URL
You can get all the applications/forms/fields deluge names. For this, you can login and access https://creator.zoho.com/api/reference to view them.

To get the Deluge name of a field from the Form,

  1. Click on “edit this application” and select the particular Form from the Forms tab.
  2. Mouse hover to the particular field name and click on “Edit this Field” link.
  3. Click on “Options
  4. You will find the field Deluge name under “Field Name for Script” section.
You can copy the field Deluge name and use it wherever you need.

You can fetch and update records from a form using Deluge script.  Let us illustrate this with the help of an example. The application Library Manager has two forms:

Books – To enter the details about each book with fields Name, Status and Author. The following books are owned by the library. The column ‘Status’ with values ‘Available’ and ‘Issued’, indicates whether the book is available in the library or is issued to any user.

Issue Book – To enter the details about the books issued. This form has a lookup field “Book Name” which imports the Books from the above form.  Only the Books whose status is “Available” is listed in the lookup field. This is achieved by specifying the criteria Status==”Achieved”, while creating the lookup field. When a Book is issued, the status of the Book is updated from “Available” to “Issued”  in the Books form.  For example, the following books are issued.

In the Books form, the Status of these books will be set to “Issued”. This is achieved using the “Issue _Book -> on add -> on success” script, given below:

Code Explanation

MyBook = Books [Name == input.Book_Name]; – Fetch records from Books form with the given criteria and store it in collection variable named “MyBook

MyBook.Status = “Issued”; – Access the Mybook variable and update the Status field with value “Issued”.

The books issued is now updated with Status as “Issued” in the Books form, as shown in the screen-shot below:

To install the application,

  1. Download the script file (.ds file)
  2. Install the application to your account. Click here to learn how to install using the script file (.ds file)

The for each syntax in Deluge scripting, enables you to conditionally fetch a collection of records and iterate over them. Let us illustrate this with the help of a simple example. The CEO of a company wants to address all the new employees who have joined after certain date say, ’10-jun-2007′ . We have to mail all these new employees. Lets see how we can achieve this.

1. Form ‘Employee’ has the following fields: Name, Qualification, EmailID, TeamName, JoinDate 

2. Write 
Form Actions -> on add -> On success script, as given below:

for each x in Employee [JoinDate > '10-Jul-2007']
To : x.EmailID
From : "yourmail@yourdomain.com"
Subject : "Meeting at 6:pm tomorrow"
Message : "As our CEO wants to address the new employees, you are requested to attend the meeting.<br>Thanks"

Code Explanation

for each x in Employee [JoinDate > '10-Jul-2007'] - Fetch the records from the Employee form with the given criteria and iterate over each record, to send mail to the EmailID of each record. Here ‘x’ is the instance variable that will represent a single record in each iteration.

sendmail – The deluge function to send mail

x.EmailID – Refers to the emailid of each record

Riko Digital acknowledges the Aboriginal and Torres Strait Islander peoples as the true custodians of the land in which we live and work.