Functions

Introduction

In DBSync Cloud Workflow, user-defined functions allow users to create custom logic that can be reused throughout their workflows. These functions can perform specific tasks, such as manipulating data or applying conditional logic. This guide will walk you through the steps to create and use a function within your workflow.

Steps to Use "Functions" Condition

  1. Login to DBSync Cloud Workflow: Navigate to the DBSync website and log in with your username and password.

  2. Navigate to the Functions Page: Once logged in, locate the Functions section in the navigation menu.

  3. Create a New Function: Click on New Function to open the Function Creation screen.

Define Your Function

  1. Enter a name for your function (e.g., 'fullName') in the designated field.

Code Example: In the code area, define the function using the appropriate syntax;

//@UserDefined
function fullName(firstName, lastName) {
    return firstName + " " + lastName;
}
  1. Save the Function: Click on Save to store your user-defined function. The function will now be available in the User Defined list on the Mapping page.

Using the Function in a Workflow

  1. Create or open a flow where you want to use the function.

  2. Drag and drop a Mapping action into your flow.

Mapping Configuration: In the mapping configuration, you can now call your defined function. For example, if you want to concatenate first and last names, you can use:

fullName(input['data'].first, input['data'].last);

Testing the Function

To test your function, you can create a Test function that calls your user-defined function with sample data:

//@Test
function test() {
    var result = fullName("John", "Doe");
    print(result); // This should output "John Doe"
}

Run the Workflow

  1. After configuring your function and mapping, click the Run icon to execute the workflow.

  2. Monitor the console output to verify that the function works as expected.

Debugging

  1. If you encounter issues, you can use a Debug action to print the values being processed. This can help you identify any errors in your function or data.

Review Results

  1. After running the integration, check the console output for any errors or confirmation messages. This will help you understand if the function executed correctly.

Pro Tip

PRO TIP

Always test your functions with various sample data to ensure they handle all possible scenarios and edge cases effectively.

Frequently Asked Questions (FAQ)

  1. Can I create multiple user-defined functions in a single workflow?

Yes, you can create and use multiple user-defined functions within a single workflow to handle different tasks and logic.

  1. What languages can I use to define functions in DBSync?

Functions in DBSync Cloud Workflow are typically defined using JavaScript. Ensure your functions adhere to the JavaScript syntax.

  1. How do I handle errors within my functions?

You can use try-catch blocks within your functions to handle errors gracefully and ensure your workflow does not fail unexpectedly.

  1. Can I reuse functions across different projects?

Yes, once defined, functions can be reused across different projects within DBSync Cloud Workflow, enhancing consistency and reducing redundancy.

Last updated