Function expressions
Last updated
Last updated
In this video, we will walk through everything you need to know about Function expressions in Easyflow.
Let’s first create a new flow with the title "Function expressions".
From the connectors panel, under the built-ins tab, you can see that Easyflow offers a variety of function expression connectors to suit your needs.
The DateTime connector allows you to perform various operations with dates, such as formatting, adding time offsets, and calculating durations.
The Conditions connector allows you to set up conditional formulas such as IF and IF-EMPTY using the same concept as Google Sheets or Microsoft Excel formulas.
The Filter connector enables you to search for and filter simple and complex lists based on desired criteria. This makes it a powerful tool for finding the specific information you need.
The Math connector enables you to build mathematical formulas and logic such as "min, max, addition, multiplication, division" and more.
You can also access and use function expressions as syntax, in a similar way to how you write formulas in Excel or Google Sheets.
This means you can write expressions in any connector. Let’s take the Mapper connector as an example.
By clicking on the "4 dots" icon located on the right side of the "Mapping Items" text box, you can see multiple tabs within the "Dynamic Content" panel.
Each tab represents a group of function expressions, such as "General," "Math," "Text," "Date and Time," and "Array" expressions.
Note that Easyflow runs "Function Expressions" in memory. This means that using "Function Expressions" either by writing Syntaxes or Configuring connectors will not have a noticeable impact on credit consumption.
For example, you may use between 5 and 10 expressions that consume 1 credit in total.
The first case, we will start with the Condition function expression. Choose the IF function option from the operation panel.
The IF function requires 3 inputs:
First, the Logical expression input: We will write A equals B. Remember to pick the equals sign from the "Operators" group from the "General Functions".
Second, we will enter "Match - using connector" in the Value when true input field.
Third, we will enter "Not Match - using connector" in the Value when false input field.
Make sure to save your changes and set the "Conditional" step as a starting point before previewing the results.
As we can see, the result returns "Not match - using connector" because the logical expression we set (A equals B) doesn't match.
Let’s change the logical expression to A equals A and preview the results again.
As we can see, the result returns "Match - using connector" as expected.
Next, we will see how to build the same logical expression we did in the first example, this time using syntax.
In this example we will use a Mapper connector as follow:
Drag the mapper connector into the workflow designer canvas.
From the mapper configuration panel, click on the "4 dots" icon located in the right side of the "Mapping Items" text box.
From the "Dynamic Content" panel, click on the General Functions tab. It's the second tab with the "Cog" icon.
Choose the IF function from the Functions group.
In the first input of the IF function, type A equals B. Remember to pick the equals sign from the "Operators" group from the "General Functions".
In the second input, we will enter "Match - using expressions".
In the third input, we will enter "Not match - using expressions"
Save your changes, set the mapper as a starting point and preview the results.
As we can see, the result returns "Not match using expression" as expected.
Let's change the expression to A equals A then save and preview the results.
As we can see, the result returns "Match using expression" as expected.
The following example will demonstrate how to use the Date and time function expressions.
The Timestamp function under the variables group returns the current timestamp in the universal timezone.
Adding a timestamp within the toDate function will convert it to a more friendly date with UTC format.
We can use the addDays expression to add days to the current date.
As you can see, writing syntaxes allows us to place nested functions within other functions. This helps us create more complex and robust logic.
In the next example, we'll connect our "Date" mapper step to a second step by dragging a built-in Date and Time connector.
Then, select the "Add Days" option from the operations list. "Add Days" requires two inputs:
The "Set the date" field should be mapped with the first step.
In the "Add number of days" field, we will enter "2000".
Save your changes and preview the results. As we can see, an additional 2000 days have been added to the date from the first step.
Let's move on to the next example, which demonstrates how to use the Text function expressions. In this example, we show how to use the replace expression to find and replace text.
In a new Mapper connector, we will type "My name is Peter" inside the “Mapping Items” text box.
After saving your changes, search for and drag the "Text functions" connector then link it to the previous step. Also, choose the replace option from the "Operations" panel.
The Replace function requires 3 inputs:
Map the “Text to search in” field with the previous step.
In the “string to search for” we will write “My name is”.
In the “string to replace the old value with” we will type “I am”.
Save your changes and set the Mapper as a starting point. Then, preview the results.
As we can see, the "My name is" got replaced with "I am" and the result returned as expected.
Thank you for watching this video.
Please feel free to contact us if you have any questions.