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.
To use script builder, select the Script tab. The user interface of the script builder is displayed as shown in the screen-shot below.
The basic steps involved in creating a form/field action script using the script builder is given below:
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.
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.
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.
The expression builder comprises of various tabs to enable you to build the required expression for each deluge statement. Each tab is explained below:
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.
This tab displays the custom variables, if any, defined by the user in the deluge script. For more information, refer Set Variable.
This tab displays the date and string variables supported by Deluge. Refer Deluge System Variables, for more information.
This tab displays the user-defined collection variables that holds one or more records fetched from a form. For more information, refer collection variables
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.
This tab displays the date, time, numeric and string functions supported by Deluge. Refer Built-in Functions for more information.
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.
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.
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.
Click on Save Script option to add the on add -> validate script to the script 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.
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.
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,
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.