Using Script Builder

 Overview

The Deluge Script Builder provides a drag-and-drop user interface to add form/field action scripts, create reports 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.

  Invoke Script Builder

To invoke Script Builder from the Form,

  • Select the required Form from the Dashboard page of your application.
  • Select Workflow - < On Add / On Edit / On Delete > -  < Actions on Load / Validate / Actions on Success > from the Form Settings icon, based on your requirement.
  • The Script Builder will be displayed.

To invoke Script Builder directly,

 Add Script using Script Builder (drag-n-drop mode)

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

 Select the Form

Select the Form. By default, the script builder displays the form selected in the Dashboard page. To select a different form, use the form drop-down list displayed next to the Functions tab.

 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.

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.

 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.

  • Drag the required task and drop it in the editor area, to display its syntax. This will display the deluge expression builder 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 each deluge statement. Refer the section deluge expression builder  to learn more about each tab.
  • 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 !=. 
  • 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.

 Using Deluge Expression Builder

The expression builder comprises of various tabs to enable you to build the required expression for each deluge statement. 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.

 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.

 User Defined Functions

This tab displays the user-defined functions that can be called from anywhere within the Deluge script.

 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.

 Save the script

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

 Adding script directly using 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.

To go to free-flow scripting mode,

Select the Free-flow Scripting link displayed in the top-right corner of the script builder. Note that the drag-and-drop tasks will not be displayed in this mode. You can directly add the required script to the editor area and save the script.  Make sure that the correct form and form action is selected before adding the script.