After reading this article you’ll know the following:
What has changed in current-gen regarding using expressions
How to create common expressions through an action step
Expressions can be viewed as formulas that help developers interact with various properties in their applications. Their values are changed depending on how the expressions are calculated. For example, expressions can be used to count the number of products in a list or the total value of a receipt, etc.
Functions we previously had to use expressions for are now being turned into blocks which you can find in the block store, from now on we advise the use of these blocks instead of expressions for the best and fastest outcome. However, if you are still limited by the public action steps, you could make use of the expression step or create one yourself as well!
Watch this video to understand more about expressions:
Getting started
Previously, within the classic-gen, builders used expressions a lot, therefore their applications were overwhelmed with unnecessary calculations that were triggered automatically. With the implementation of the current-gen, the calculations done with expressions are simplified and combined with the functionality of the actions for your convenience. In this article, we will show how you can create dynamic data using expressions in the action steps.
Let’s take an example of creating a simple (single-line) text expression where we will add two properties (values): First name + Last name = Full name.
First, make sure you have the needed properties within your model. |
Building the action flow
Before starting off, we need some input data in our action. It can be added in a variety of ways. In this case, we will use a simple form component that will bring some input variables (First name and Last name here) with it and will automatically create an action.
Go to the page builder and add the form component to the page's canvas. In its configuration, select our previously created model (Webuser), choose the desired properties (First name and Last name), and click
After that, navigate to our form component's options and press the pencil icon in front of a newly created action that will redirect you straight to the action flow. Notice that when you press the start action step, it will contain two of our input variables (First name and Last name).
Note: If you use some other form page components like Create or Update forms, the action flow we are going to build will be pre-created by default, but instead we chose the other way around for you to comprehend the process in detail. |
Now we need a specific function that will be able to add up these properties to get a third one - Last name. Go to the block store and find a function block called Concat and install it to your application. This function serves as a simple expression to combine two text values with an optional operator, which is exactly what we need in our case. |
Drag the Concat function onto the canvas to add another action step. Then fill in the options of this step:
Press
|
Lastly, we need to get the user’s full name as an outcome of this action flow. Drag the Create record step below the Concat step and fill in the following options:
And of course, click |
Using expressions in the actions simplifies the workflow in your application. The action triggers only important calculations whenever you need them. We are also actively working on extending functionalities and you can view the list of public functions with descriptions in this article.