You can use your own custom functions in formulas in your application. There are three types of custom functions you can add:
Local extensions: Functions specific to the page, record or table control.
Application-wide extensions: Functions available for the entire application to use.
Importing .NET Framework classes and functions: You can use any .NET Framework class by importing the class in the formula functions.
For localized extensions, you can add functions at the page, table control or row control levels. Specifically, the formula language exposes variables for page object as well as the table control, record control and row objects. So you can call any function you want on these classes as well.
For example, on the ShowCategoriesTable.aspx displaying a Categories table page, you can define functions on the ShowCategoriesTable page class, on the CategoriesTableControl class, or on the CategoriesTableControlRow class as needed.
As an example, if you defined the following non-shared (VB.NET) or non-static (C#) functions:
In the ShowCategoriesTable class, define the GetPageValue() function.
In the CategoriesTableControl class, define the GetTableValue() function.
In the CategoriesTableControlRow class, define the GetRowValue() function.
On the Formula tab, these formulas can be used to access each of these functions respectively:
= Page.GetPageValue()
= CategoriesTableControl.GetTableValue()
= CategoriesTableControlRow.GetRowValue()
Each of these functions can return a constant, another value local to their respective objects, call a function in another class, call another shared function on another class, another DLL or any other function that is possible to implement in the application.
Note that these formulas are context sensitive. The Row function can only be called from within a row because the CategoriesTableControlRow variable is only accessible from the row. Similarly, the Table function can be called from within the row or when within the table area (e.g., filters or buttons area). The Page function can be called from anywhere on the page.
The formula functions for an application are implemented in two source code files within the application’s source code. New formula functions can be added to these files, or existing functions can be modified as desired.
The formula functions are split into two files because some functions cannot be used within the WHERE clause of a query. For example, the SUM, RANK or ROWNUM functions are specific to the presentation layer since they operate on textbox, literal and label controls on the web page. These functions can only be used in the Property Sheet and cannot be used in the WHERE clause of a query. Most functions however are generic and can be used in either the Property Sheet or the WHERE clause of a query.
BaseFormulaUtils.vb or BaseFormulaUtils.cs: Located in the \Data Access Layer\Shared folder, this file contains all the formula functions that are available in common to both the data access layer and the presentation layer.
FormulaUtils.vb or FormulaUtils.cs: Located in the \Shared folder, this file contains all the formula functions that are available only at the presentation layer. These functions cannot be used in the WHERE clause of a query.
Any shared or static functions from either the .NET Framework or your own classes can be used by importing their types in the FormulaUtils.vb or FormulaUtils.cs class and registering them via the Evaluator.Imports.AddType() function, e.g.:
Evaluator.Imports.AddType(GetType(Math), "Math")
Evaluator.Imports.AddType(GetType(DateTime), "DateTime")
Evaluator.Imports.AddType(GetType(Convert), "Convert")
Evaluator.Imports.AddType(GetType(String), "String")
The first argument is the type and the second argument is the prefix (or namespace) used to refer to the function.
Variables Available in Formulas
Using Table and Record Control Functions in Formulas
Using .NET Framework Functions in Formulas
Using Custom Functions in Formulas