Overview
The functions defined in the Functions tab can be called and executed
from form/field action scripts. 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
1. To call a function directly,
- Select the Forms tab, and select the required form/field
actions.
- Add the Call Function statement, as shown below and click
on Edit to specify the function name, namespace and values
to the argument. For example, let us call the display function
by specifying the value of argument a as the ID of
a record.

2. Click Done to update the changes. The function display
is called in the On success script with the input.ID as
value of argument a.

When an entry is added to the form, the display function will be called
which will display the record ID of the current record as a log message.
Calling Functions from "User
Defined Function" tab in expression builder
1. Let us define a CalculateDays function to calculate
the number of dates within two date Fields. The function has two arguments
sdate and edata 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 statement -> User Defined Function
tab in expression builder. The Set variable statement will set the Number_of_days
field in the Sampleform with the value of days returned
by the CalculateDays function. The arguments sdate and edate
is replaced with the Input Fields Start_Date and End_Date.

When a record is submitted in the SampleForm, 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.