Invoking a Function


The functions defined in the Functions tab can be called and executed using scripts at various Form Action and Field Action blocks. You can call a function directly from the Call Function deluge statement or from User Defined Function tab in expression builder, based on your requirement.

 Calling Functions Directly

To call a function directly,

  • Select the Forms tab, and select the required Form/Field action.
  • Drag and drop the Call Function deluge task, to the script builder area.
  • In the dialog box displayed, specify the function name, namespace and values to the argument . For example, let us call the CalculateDays function by specifying the value of argument as sdate and edate.
  • Click Done to add the function to the script builder.

 Calling Functions from "User Defined Function" tab in expression builder

1. Let us define the CalculateDays function to calculate the number of days within two date Fields. The function has two arguments sdate and edate of type date with return type int, as shown below:

2. Now, we will call this function from the On Add -> On Success -> Set Variable task in expression builder. The Set variable statement will set the Number_of_days field in the form with the value of days returned by the CalculateDays function. The arguments sdate and edate is replaced with the Input FieldsStart_Date and End_Date.

3. When a record is submitted in the form, the on add -> on success script is invoked, which executes the CalculateDays function and updates the Number_of_days field with the value returned by the function.