What is a function?

Created by Ed Chalon, Modified on Fri, 30 Jun, 2023 at 8:05 PM by Scott Knudson

Below is a comprehensive guide to the functions available in the Limble Fuse scenario editor, including their functionalities, examples, and how to use them effectively. 


To access functions, they are available either: 

a. When working with fields of a module:


b. In the custom functions are of Limble Fuse: 



1. Mathematical Functions:

- Addition: Performs addition of two or more numerical values. Example: `2 + 3` returns `5`.

- Subtraction: Calculates the difference between two numerical values. Example: `5 - 2` returns `3`.

- Multiplication: Multiplies two or more numerical values. Example: `2 * 3` returns `6`.

- Division: Divides one numerical value by another. Example: `10 / 2` returns `5`.

- Modulo: Computes the remainder of a division operation. Example: `10 % 3` returns `1`.

- Power: Raises a number to a specified power. Example: `2 ^ 3` returns `8`.


2. String Functions:

- Concatenation: Combines multiple strings into a single string. Example: `"Hello" + "World"` returns `"HelloWorld"`.

- Length: Returns the number of characters in a string. Example: `length("Hello")` returns `5`.

- Substring: Extracts a portion of a string based on specified start and end positions. Example: `substring("HelloWorld", 1, 5)` returns `"ello"`.

- Upper/Lower Case: Converts a string to uppercase or lowercase. Example: `uppercase("hello")` returns `"HELLO"`, and `lowercase("WORLD")` returns `"world"`.

- Replace: Replaces a specified substring within a string with another substring. Example: `replace("Hello World", "World", "Universe")` returns `"Hello Universe"`.


3. Date and Time Functions:

- Current Date/Time: Returns the current date or time. Example: `currentDate()` returns the current date.

- Date Calculation: Performs calculations on dates, such as adding or subtracting days, months, or years. Example: `addDays(currentDate(), 7)` adds 7 days to the current date.

- Format: Converts a date or time value to a specified format. Example: `format(currentDate(), "yyyy-MM-dd")` returns the current date in the format "2023-06-30".

- Timezone Conversion: Converts a date or time value from one timezone to another. Example: `convertTimeZone(currentTime(), "UTC", "America/New_York")` converts the current time from UTC to the timezone of America/New_York.


4. Logical Functions:

- IF Statement: Evaluates a condition and returns one value if the condition is true and another value if the condition is false. Example: `IF(condition, value_if_true, value_if_false)`.

- Comparison Operators: Compares two values and returns a Boolean (true/false) result. Examples: `1 > 2` returns `false`, `3 <= 5` returns `true`.

- AND/OR Operators: Combines multiple conditions and returns a Boolean result. Example: `condition1 AND condition2` returns `true` if both conditions are true.

- NOT Operator: Negates a Boolean value. Example: `NOT(condition)` returns `true` if the condition is false.


5. Data Conversion Functions:

- Number Conversion: Converts a string or other data type to a numeric value. Example: `toNumber("10")` returns `10`.

- String Conversion: Converts a numeric or other data type to a string. Example: `toString(42)` returns `"42"`.

- Boolean Conversion: Converts a value to a Boolean (true/false) representation. Example: `toBoolean("true")` returns `true`.


6. Custom JavaScript Functions:

In addition to the built-in functions provided by Limble Fuse, users also have the flexibility to write custom JavaScript functions to address specific requirements that might not be covered by the available functions. This feature allows you to extend the functionality of Limble Fuse and tailor your automation scenarios to your unique needs. Here's how you can write and use custom JavaScript functions:


Writing Custom Functions:

To create a custom JavaScript function in Limble Fuse, follow these steps:

a. Open the Limble Fuse scenario editor and navigate to the Function module.

b. Add a new Function module to your scenario by clicking the "+" icon.

c. Provide a name for your custom function. Ensure the name is unique and meaningful.

d. Write the JavaScript code for your custom function within the module's code editor.


Function Syntax and Structure:

When writing custom JavaScript functions in Limble Fuse, adhere to the syntax and structure of JavaScript functions. Here's an example of a basic custom function:

```javascript

function customFunction(parameter1, parameter2) {

  // Function logic and operations

  var result = parameter1 + parameter2;

  return result;

}

```


Function Usage:

Once you have defined a custom JavaScript function, you can utilize it within other modules in your scenario. To use a custom function, follow these steps:

a. Within a module (e.g., Data Manipulation module or Action module), locate the field where a function is required.

b. In the field, enter the function call using the function's name and provide the necessary arguments. Example: `customFunction(2, 3)`.


Accessing Context Variables:

Custom JavaScript functions in Limble Fuse have access to context variables, which are variables that can store and retrieve values throughout the scenario execution. These variables can be used as inputs or outputs for your custom functions, providing flexibility and data persistence across modules.


Advanced JavaScript Functionality:

When writing custom JavaScript functions, you have the full power and flexibility of the JavaScript language at your disposal. You can incorporate conditional statements, loops, data manipulation, and interact with external APIs, libraries, or services using JavaScript libraries.


Important Considerations:

- Custom JavaScript functions should be written following best practices and adhere to the JavaScript syntax rules.

- Care should be taken to handle errors and validate inputs within custom functions.

- Testing and validating custom JavaScript functions within the scenario editor is recommended to ensure their proper functionality.


Remember, writing custom JavaScript functions offers an advanced level of flexibility and customization within Limble Fuse. It allows you to leverage the full potential of JavaScript to address complex scenarios or specific business requirements.


However, it's essential to exercise caution when using custom JavaScript functions, as improper code implementation or errors can impact the overall performance and stability of your scenarios. Always test and validate your custom functions thoroughly before deploying them in production scenarios.


In conclusion:

Utilize the power of custom JavaScript functions in Limble Fuse to expand the capabilities of your automation scenarios and unlock endless possibilities for customization and integration.

These functions can be used within various modules, such as data manipulation modules or conditional statements, to perform calculations, manipulate data, or make decisions based on specific conditions.


It's important to note that the above examples represent a subset of the available functions in Limble Fuse. The platform offers a rich library of functions, and additional custom functions can be created to cater to specific needs using the Function module. Experimenting with these functions within the scenario editor, exploring their outputs, and understanding how they integrate into your automation scenarios will help you unleash the full potential of Limble Fuse's functions.




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article