Functions
Create customized functions to utilize in Workflows
By Definition, a Function is a group of statements that, together, performs a task. In DBSync, Functions are categorized as:
Standard Functions
User Defined Functions
Standard Functions
Standard Functions, or built in Functions, refer to specific Function by name. Functions are available to all users of a project. If a project is imported, the same files and Functions, from the original project, are available to the cloned project.
Functions are code sensitive. When you are using Functions, the string objects must be enclosed in single quote
The Standard Functions are listed, in detail, in the iPaaS section. Click on the Standard Functions to learn about the inbuilt Functions offered by our DBSync iPaaS.
User Defined Functions
User-Defined functions are those functions that are defined by the user from the DBSync platform. Functions are used for code reuseability and to save time and space.
At present, DBSync platform supports creation of UDF in JavaScript.
Benefits
It provides modularity. As a result, a user can create once and then, reuse it across any project that allows create once and reuse n number of times.
Easy code reusability. You just have to call Functions by its name to reuse it.
Tutorial
Follow the video walkthrough to create and test a sample function.
Creating a User Defined Function
All User Defined Functions have to be followed with the header "//@UserDefined" for DBSync to recognize it as User Defined Function. When done so, it is populated in the UserDefined list of the "Mapping page".
User has to login to DBSync iPaas and navigate to Functions page.
Click on New Function. This will navigate a User to a Function Creation screen.
Name a Function of his/her choice and define the Function in the space provided.
Click on Save to save the User Defined Function.
Use the following code to test the function
Testing a Functions
To test a User Defined Function, it has to be accompanied by a method generally started with header "//@Test". The user must save the created Function before testing it.
The following code snippet shows the Test method required to test the User defined function for name:
Code
Testing
The following screen shows the User Defined Function along with Test method required to execute it.
After writing the Test method, immediately after the UDF, it is best practice to Save. The Save button is located at the top right corner of the page .
Here, a user is prompted to select the available Test Methods in a pop-up. As a result, s/he can select the appropriate name and click on "Run Tests" button.
Finally, the number of code lines executed is shown on the Top ribbon.
Last updated