Discuss

Using Set Value in Server Connect

On this page

The Set Value step in Server Connect can be useful in many cases. You can think of it as a variable where you can store any kind of static or dynamic values. These values can then be accessed in any of the server action steps, also they can be outputted on your pages. You can store any dynamic data with the Set Value step - query results, inserted or updated record's ID, calculations, logged user's ID and more. In this tutorial we will show you a basic example, explaining how to store the average value of a database query and then displaying it on our page.


Creating the Set Value step

We created a database query, which returns some information about the airports across the world. We want to calculate the average altitude in a Set Value step.

Screenshot_41|690x397

Creating the Set Value step is simple, just right click the database query and under core actions, select Set Value:

Screenshot_42|690x397

Add a name for this variable. We call it my_value:

Screenshot_43|690x397

Then, let's assign a value to it - click the dynamic data picker button:

Screenshot_44|690x397

Select the database query and click the Server Data Formatter icon:

Screenshot_45|690x397

Open the Collections menu and select Avg (Average):

Screenshot_49|690x397

Then enter the property (database column) which average value you want to calculate. In our case it's called alt:

Screenshot_50|690x397

Click the select button:

Screenshot_51|690x397

If you want to output this value on your page(s), then you need to enable the Output option:

Screenshot_52|690x397

Displaying the value on your page

Close the Server Connect Panel and open the App Structure Panel. We've already added the server connect component there and it returns the data from our server action:

Screenshot_53|690x397

Let's add some static text on our page. Click the add component button:

Screenshot_54|690x397

Add a title:

Screenshot_55|690x397

Double click to edit the title and use the dynamic data button:

Screenshot_56|690x397

Your Set Value step will appear under data in your server action. Select it:

Screenshot_57|690x397

Save your page and see the results:

Screenshot_58|690x397