Skip to main content
All CollectionsActions
How to create expressions (in actions)
How to create expressions (in actions)

Create expressions to calculate values via your application’s actions.

Betty Blocks avatar
Written by Betty Blocks
Updated over a year ago

Warning!

You’re now reading a legacy document. The features described below are only usable within the classic generation environment. Proceed to this article if you are working with next-gen.


Description

Expressions are properties that can handle a certain logic, these are formulas that use your application data to get you a specific result. Their value can change depending on how the expression is calculated. For example, expressions can be used when you need to calculate the total price for all products in a list or get the first and last names added automatically to show the full name of a user.

Considered as pieces of custom functionality, expressions can be used in several places in your application: in the data model or in actions. In this article, we will look at how to use them in your application's actions to get specific and complex results you will not be able to get from static data model properties.

Setting up for using expressions

In the following example, we will go through creating a simple text (single line) expression in the already existing data model.

Open the data model section and choose the needed model. In our example, it will be the “Webuser”.

After the ‘Webuser’ model is open, you will see all of its properties in the list. The underlined ones - ‘First name’ and ‘Last name’ are those that we will use to combine in the new property that will be called ‘Full name’.

Click on the ‘New property’ button and create a new property in a slide-out panel. We will keep this property with no value and add an expression through the actions module. Fill in the name and save your progress.

Creating expression property via actions

The next thing we need to do is open the actions in the previous environment.

Note: After clicking the ‘Edit in previous environment’ option, you might not get exactly to the actions module. In this case, just click on the actions once again.

Here you will see different actions generated via the page builder. The action we need is the ‘Create webuser action’. Click once to open it.

First of all, let’s add the ‘Create webuser’ action. Click on “+” to create an action step.

Select the following options in the action event configuration window:

  • Kind: Create

  • Model: Webuser

  • Assign:

Property Value

First name var:record.first_name

Last name var:record.last_name

  • As: new_webuser

Click ‘Save’ when finished. Now we will add one more action step - the ‘Update’ step as we want our newly created record to be updated with the full name.

In the next window we will go through configuring this action step:

  • Kind: Update

  • Object: new_webuser

  • Assign: Property - Last name

At the bottom of the page click on ‘Add’ to create a new variable.

Here we will choose a text expression and type in its name.

In the text field, insert two variables: ‘First name’ and ‘Last name’, divided by ‘+ “ “ +’, so it will look as follows:

var:new_webuser.first_name + “ “ + var:new_webuser..last_name

Come back to the assign section and add the newly created expression to the property’s value.

Click on ‘Save’ to finish the setting.

Now each time a new webuser is created, the update event will happen after it, combining the first and the last names of webusers into the full name.

Learn more about the expressions you can apply here.

Did this answer your question?