Creating User Defined Functions

Create custom functions such as a complex calculation or a predefined logic using the User Defined Functions feature. You can save the functions and reuse them in data flows.

Accessing User Defined Functions

To access User Defined Functions, follow these steps:
  1. On the Workspaces page, from the list of workspaces, select the workspace for which you want to create a function.
  2. On the home page of the workspace, click User Defined Functions. Alternatively, from Quick Actions, select User Defined Functions.
The user-defined functions library page is displayed.

Creating a Library

You create and organize functions in a library. To create a library:
  1. Navigate to the Function libraries page and click Create library.
  2. In the Create function library page that appears, enter the following details:
    • Name: Enter a name for the library.
    • Identifier: Based on the name that you enter, an identifier for the library is created.
    • Description: Enter a description for the library.
  3. Click Create.
The library is created and you are navigated to its details page.

Viewing Library Details

After you create a library, you are navigated to its details page. To view the details of an existing library:
  1. On the Function libraries page, from the list of libraries, select the library for which you want to view the details.
  2. From the Actions menu, select View Details.
The details page of the library is displayed.

Adding Function Parameters

Create parameters that you can use in your function. To create input parameters:

  1. In the Functions section of the library details page, click Create function.
  2. In the Create User Defined Function panel that appears, in the Expression builder section, click Input parameters.
  3. From the Actions selection list, click Add input parameters.
  4. In the Add input parameters panel that appears, enter the following for the parameter that you want to add:
    • Name: Enter a name for the input parameter.
    • Description: Enter a description for the input parameter.
    • Data type: From the list, select the data type.
  5. To add another parameter, click Additional parameter, and then enter the parameter information. Repeat the procedure to add more parameters.
  6. When you have finished adding one or more parameters, click Add.
  7. In the Create User Defined Function panel, click Create.

Creating a Function

You create a function from the library details page. To create a function:
  1. In the Functions section of the library details page, click Create Function.
  2. In the Create User Defined Function panel that appears, enter the following details:
    • Name: Enter a name for the function.
    • Identifier: Based on the name you enter, a unique identifier is generated for the function.
    • Description: Enter a description for the function.
    • Return data type: From the list, select the data type.
    • In library: Displays the name of the library in which the function is getting created. To change the library, click the Edit link.
  3. In the builder section, do the following:
    1. From the Functions tab, expand the function from which you want to add an expression and select the expression. The expression is added to the expression builder on the right.
    2. To complete the expression, select the input parameters with the required calculations. For example, for a function to calculate tax, add input parameters for base salary (base), flexible benefits (flexi), and deductions (deductions), and then build the expression as base + flexi - deductions.
    3. To validate the expression, click Validate.
  4. Click Create.

Editing Function Parameters

After you create input parameters for a function, you can use the Actions menu to edit, move, or delete an input parameter.

Editing a Function Parameter
To edit a function parameter:
  1. On the Function libraries page, select the library that has the function in which the parameter that you want to edit resides.
  2. In the Functions section of the library details page, select the function that has the parameter you want to edit.

    Alternatively, you can select Edit from the Actions menu.

  3. In the Edit User Defined Function panel that appears, click Input parameters.
  4. From the Actions selection list, click Edit input parameters.
  5. In the Edit input parameters panel that appears, from the Actions menu of the parameter that you want to edit, select Edit.
  6. In the panel that appears, make the required changes to the name, description, or data type fields, and then click Save Changes.
  7. In the Edit input parameters panel, click Save Changes.
  8. In the Edit User Defined Function panel, click Save Changes.
Deleting a Function Parameter
To delete a function parameter:
  1. On the Function libraries page, select the library that has the function in which the parameter that you want to delete resides.
  2. In the Functions section of the library details page, select the function that has the parameter you want to delete.

    Alternatively, you can select Edit from the Actions menu.

  3. In the Edit User Defined Function panel that appears, click Input parameters.
  4. From the Actions selection list, click Edit input parameters.
  5. In the Edit input parameters panel that appears, select the parameters that you want to delete and click Delete.
  6. In the Delete parameter dialog that appears, click Delete.
  7. In the Edit input parameters panel, click Save Changes.
  8. In the Edit User Defined Function panel, click Save Changes.

Managing Libraries and Functions

After you create a library, you can edit, duplicate, or delete it. Similarly, you can edit, move, or delete a function.

Editing a Library
To edit a library:
  1. On the Function libraries page, select the library that you want to edit, then click Edit.
  2. On the library details page, click Edit.
  3. In the Edit function library page that appears, make the required changes to the name and description of the library.
  4. Click Save Changes.
Editing a Function
To edit a function:
  1. On the Function libraries page, select the library in which the function that you want to edit resides.
  2. In the Functions section of the library details page, select the function that you want to edit.

    Alternatively, you can select Edit from the Actions menu.

  3. In the Edit User Defined Function panel that appears, make the required changes.
  4. Click Save Changes.
Duplicating a Library

You can create a library by duplicating an existing one. To duplicate a library:

  1. On the Function libraries page, for the library you want to duplicate, select Duplicate from the Actions menu.
  2. In the Duplicate library dialog box that appears, enter a name for the library.

    The Identifier field displays the unique identifier based on the name that you enter. You can change the identifier value, but after you create the duplicate object, you can't update the value.

  3. Click Duplicate.
Moving a Function
You can move a function from one library to another. To move a function:
  1. On the Function libraries page, select the library in which the function that you want to move resides.
  2. In the Functions section of the library details page, for the function you want to move, click Move from the Actions menu.
  3. In the Edit library location dialog that appears, from the Library location list, select the library to which you want to move the function.
  4. Click Save.
Deleting a Library
To delete a library:
  1. On the Function libraries page, from the list of libraries, select the name of the library that you want to delete, then click Delete.
    Alternatively, for the library that you want to delete, click Delete from the Actions menu.
  2. In the Delete Library dialog box that appears, enter delete to confirm the deletion.
  3. Click Delete.
Deleting a Function
To delete a function:
  1. On the Function libraries page, from the list of libraries, select the name of the library in which the function that you want to delete resides.
  2. In the Functions section of the library details page, for the function that you want to delete, click Delete from the Actions menu.
  3. In the Delete Function dialog box that appears, click Delete.

Using the API