Using Script Builder

Overview

The Deluge Script Builder provides a drag-and-drop user interface to add form/field action scripts, create views with complex criteria/filters and define functions that can be reused from elsewhere in scripting. It enables you to transfer complex application logic into deluge code, without the need to learn or remember the Deluge syntax and functions. It helps in creating Deluge action scripts quickly, without any errors.

User Interface

To use script builder, select the Script tab. The user interface of the script builder is displayed as shown in the screen-shot below.

 

Using Script Builder to add Form/Field Actions

The basic steps involved in creating a form/field action script using the script builder is given below:

Select the Forms Tab

  • The Forms tab is used to add form/field action scripts. This tab is selected by default.
  • The Views tab displays the script definition of the views.
  • The Functons tab is used to add new functions or modify/delete existing functions.

Select the Form

When the Forms tab is selected, the forms created in the application will be listed in the Select Form list box displayed below the Forms tab. Select the required form for which the action script needs to be added.

Select the Form/Field Action

The Form Actions lists the on load, validate and on success form actions that invoke a script execution. For example, to invoke a validation script that validates form data before submitting it to the database, select Form Actions -> on add -> Validate. Refer the topic Form actions for more information on each form and field actions supported by Deluge.

The Field Actions lists the on user input and on update actions for each field in the selected form, that invoke a script execution. For example, to invoke a script when you change the value of a field in the form, select Field Actions -> <Field_Name> -> On user input. Refer the topic Field Actions, for more information on each form and field actions supported by Deluge.

Drag and drop the Deluge statements

The script builder displays the tasks/statements that can be used to perform form and field actions. Let us learn how to add a simple validate script that allows only the admin user to add records to the Employee form.

  1. Drag the required task and drop it in the editor area, to display its syntax. In the screen-shot given below, the If statement is selected and dropped in the editor area. The syntax of the If statement is displayed in the editor area.

  2. Select the Edit button to configure the If condition. This will display the expression builder dialog as shown in the screen-shot given below. The Deluge expression builder comprises of various tabs to enable you to build the required expression for your script. Each tab is explained below:

    • Input fields: This tab displays all the fields in the selected form. Selecting a field will add the syntax input.<fieldName> to the text area below and refers to the value of the field input in the form.

    • User-defined variables: This tab displays the custom variables, if any, defined by the user in the deluge script. For more information, refer Set Variable.

    • Zoho variables: This tab displays the date and string variables supported by Deluge. Refer Deluge System Variables, for more information.

    • Collections: This tab displays the user-defined collection variables that holds one or more records fetched from a form. For more information, refer collection variables

    • User Defined Functions: This tab displays the user-defined functions that can be called from anywhere within the Deluge script. For more information on defining functions, refer Functions.

    • Built-In functions: This tab displays the date, time, numeric and string functions supported by Deluge. Refer Built-in Functions for more information.

    • Old Field Values: This tab will be displayed only while configuring the on edit -> validate script. It displays all the fields in the selected form. Selecting a field will add the syntax old.<fieldName> to the text area below and refers to the previous value held by the field, before editing. You can refer the old field values to perform calculations or store the record history. Refer the topic Tips & Tricks -> Storing Previous Record History for more information on this use case.

  3. Build the required expression using the values displayed for the selected tab and the operators displayed. For example, the if condition input.Added_User != zoho.adminuser is added by selecting the input field Added_User and comparing it with the Zoho variable zoho.adminuser using the operator !=. Refer the topic Deluge Reference -> Operators, for more information.

    Note IconNote:

    Zoho Creator automatically tracks details about when and by whom a record was added or modified using the fields Added User, Added Time, Modified User and Modified Time. This information will be displayed in the view, if the columns are selected from Column Properties option of the View tab in Edit mode.


  4. Click Done to add the expression to the editor area, as shown in the screen-shot below. We have also added the If statements, alert and cancel submit, that will be executed, if the condition is satisfied. (i.e) If the added user is not equal to the admin user, an alert message will be displayed and the submission will be cancelled.

Save the Script

Click on Save Script option to add the on add -> validate script to the script definition.

Form Definition

You can view the complete script definition of the Employee form, including the form/field action scripts, by selecting Form Definition -> With Action as shown in the screen-shot below. The form definition comprises of the form name, field name and type and action scripts, if any, configured for this form. Each field definition in this form, comprises of the Deluge field name, display name and the field type. By default, the label name is the deluge field name. If the label name consists of white space for example, Postal Address, the deluge field name will be taken as Postal_Address.

Free-Flow Scripting

If you are well-versed with Deluge Scripting or if you have the script code ready, you can switch on to Free-flow scripting mode to create your script without the use of the drag-and-drop editor. Refer FAQ -> Deluge Scripting , for more information on defining forms and fields in Deluge.

 

Using Script Builder to create views with complex criteria/filters

The Views tab of the Script Builder displays the script definition of the views created in the GUI mode. Though you can set criteria/filters from the GUI itself, deluge scripting is needed to define complex ones, like having both a AND and an OR operator or criterias that use deluge system variables. You can select a specific view from the Select View list box to display the view definition in the editor area.

In the screen-shot given below, the view definition of the Employee Form View is displayed, where,

  • list is the display format of the view. In list view, the form data will get displayed as a table.
  • Employee Form View is the view name
  • Employee_Form is the form name
  • show all row from Employee_Form is the syntax to display all the rows in the form named Employee_Form
  • [(((Email is not null) && Employee.contains("John")) || Employee.startsWith("J"))] is the view criteria. If no criteria is specified, all the records in the form will be displayed in the view.

Related Links

Deluge Reference - Criteria/Filters
Deluge Tips - Filtering Data in Views

Using Script Builder to Define Functions

The Functions tab in Script Builder displays all the functions configured in the application. You can add new functions, modify or delete existing functions. In the screen-shot given below, the isLeapYear() function is added to the Function tree.

For more information on configuring and calling functions, refer the topic Deluge Reference -> Functions.