Components > User-defined functions > Creating user-defined functions
  

Creating user-defined functions

Create a user-defined function on the New Asset page. The user-defined functions that you create are available to all users in your organization based on their privileges.
    1. Click New > Components > User-Defined Function and then click Create.
    2. Configure general properties such as the function name, location, and return type.
    3. Optionally, create arguments for the function.
    When you create arguments, configure the name, data type, and description for each argument.
    4. Create the function expression.
    5. Validate and save the function.

User-defined function general properties

When you create a user-defined function, you must define general properties such as the function name and return type. Define general properties on the General tab.
The following table describes the properties:
Property
Description
Name
Name of the function. Must be unique within an organization.
The name must begin with a letter and can contain letters, numbers, and the following special characters:
_ @ $ #
The name cannot exceed 100 characters and cannot contain spaces.
Location
Location of the user-defined function. Browse to the folder where you want to store the user-defined function or use the default location.
The default location is the location of the most recently saved asset.
Description
Description of the user-defined function.
The description appears in the expression editor when you select the function in a transformation expression, a field expression, or another user-defined function.
Return Type
Data type of the values that the function returns. Can be binary, date, numeric, or string.

User-defined function arguments

When you create a user-defined function, you can include arguments to define the values that you pass to the function. Create arguments on the Arguments tab. You can create up to 10 arguments.
To create an argument, click Add, and enter the following information:
Property
Description
Name
Name of the argument. Must be unique within the function.
The name must begin with a letter and can contain letters, numbers, and underscore characters (_). It cannot exceed 100 characters and cannot contain spaces.
Type
Data type of the argument. Can be binary, date, numeric, or string.
Description
Description of the argument.
The description appears in the Arguments and Functions area on the Expression tab when you select the argument. It also appears in the expression editor when you use the function in a transformation or field expression.
Arguments are passed to the function in the order in which they appear on the Arguments tab. To rearrange the order, select an argument and click Move up or Move down.
To delete an argument, click Delete in the row that contains the argument.

User-defined function expression

Create the expression that defines the function on the Expression tab. The function expression can contain constants, operators, built-in functions, and other user-defined functions. You can create a complex expression by nesting functions within functions.
To create an expression, enter the expression in the expression editor. The expression that you create must follow the same guidelines and use the same syntax as any transformation or field expression. For more information about creating expressions, see Tasks.
You can add arguments, built-in functions, and other user-defined functions to the expression by selecting them in the Arguments and Functions area of the expression editor and clicking Add. You can also type in the expression manually.
An expression cannot contain cyclic references. For example, the expression for user-defined function Function_A cannot include Function_A. Also, if user-defined function Function_A calls user-defined function Function_B, then the expression for Function_B cannot call Function_A.
To validate the expression, click Validate. Data Integration validates the expression. It does not validate the user-defined functions and expressions that use the function.