Creating a Custom Function

This post is referring to Vahana 2 (beta version). To check the document for production, please go to vDesigner-v1.0

In the Cutsom Function submodule, creating a custom function includes several small sub-steps. It provides intuitive and clean user interfaces to define a custom function. After you create a custom function, you can test it. When you want to use a custom function, you can consume it by using the Invoke Function task.

Creating a custom function includes the following steps:

These sub-steps are broadly described as follows:

Creating a New Custom Function

To create a new function:

  1. On the vDesigner module’s dashboard, see the left navigation panel.
  2. In the left navigation panel, click the Custom Function icon () icon to display the Custom Function page.
  1. On the Custom Function page, click Create New, and a Custom Function panel comes into view.
  1. In the Custom Function panel, the Input Parameters tab is selected by default.
  1. Under Create New, in the Name box, enter the custom function’s name.
  2. In the Description box, enter a brief reason to create the custom function.

Defining Input Parameters

To create a custom function, you write the logic or algorithm of the custom function in the JavaScript language. After you write the code of the custom function, you can define the list of input parameters.

This heading section describes the custom function with the example to write the code of the custom function. This sample code contains the algorithm to calculate the BMI based on the height and weight of a person.

To define the custom function and input parameters:

  1. On the Create New page, in the Custom Functions panel, the Input Parameters tab is selected by default.
  2. In the Input Parameters tab, in the Javascript Editor box, enter or write the code of the custom function.
  1. After you enter the code of the custom function, define the function’s name and input parameters as described in the following steps:
  2. In the Primary Function Name box, enter the name of the function (for example, calculateBMI) that contains the algorithm of the custom function.
  3. In the Parameters box, enter the parameter’s name (for example, weight).
  4. In the middle box, select the data type (for example, Integer) of the parameter.
  5. In the Description box, enter a brief description of the parameter.
  1. Click Add New to add details of another parameter.
  2. To add details of another parameter, repeat steps from step 5 to step 7.

After you enter the code of the custom function and define the details of parameters, you need to define the output’s type. Defining output’s type in the following section:

Defining Output Type

After you define input parameters, you need to define the output type. To define the output’s type, you select a data type from the list of predefined data types. Selecting a data type determines the data type of the output’s value.

To define the output’s type:

  1. In the Custom Functions panel, click the Output tab.
  1. Click the Output box, and then select the data type (for example, Integer) of the output.
  2. After you select the data type, click to create a new custom function.

Was this article helpful?
YesNo