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.
To call a function directly,
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 Fields Start_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.