Supported JavaScript annotations for custom function
JavaScript annotations are used to provide metadata for JavaScript code. It includes comments that start with specific symbols, for example, /** and @. The annotations provide important information about functions, variables, and other elements in the code. Adaptive Form supports the following JavaScript annotations for custom functions:
Name
The name is used to identify the custom function in the rule editor of an Adaptive Form. The following syntaxes are used to name a custom function:
@name [functionName] <Function Name>
@function [functionName] <Function Name>
@func [functionName] <Function Name>
.functionName
is the name of the function. Spaces are not allowed.<Function Name>
is the display name of the function in the rule editor of an Adaptive Form.
If the function name is identical to the name of the function itself, you can omit[functionName]
from the syntax.
Parameter
The parameter is a list of arguments used by custom functions. A function can support multiple parameters. The following syntaxes are used to define a parameter in a custom function:
-
@param {type} name <Parameter Description>
-
@argument
{type} name <Parameter Description>
-
@arg
{type}
name <Parameter Description>
.{type}
represents the parameter type. The allowed parameter types are:- string: Represents a single string value.
- number: Represents a single numeric value.
- boolean: Represents a single boolean value (true or false).
- string[]: Represents an array of string values.
- number[]: Represents an array of numeric values.
- boolean[]: Represents an array of boolean values.
- date: Represents a single date value.
- date[]: Represents an array of date values.
- array: Represents a generic array containing values of various types.
- object: Represents form object passed to a custom function instead of passing its value directly.
- scope: Represents the globals object, which contains read-only variables such as form instances, target field instances, and methods for performing form modifications within custom functions. It is declared as the last parameter in JavaScript annotations and is not visible in the rule editor of an Adaptive Form. The scope parameter accesses the object of the form or component to trigger the rule or event required for form processing. For further information on the Globals object and how to use it, click here.
The parameter type is not case-sensitive and spaces are not allowed in the parameter name.
<Parameter Description>
contains details about the purpose of the parameter. It can have multiple words.