Overview
In this lesson, we are going to focus on “Variable” control under the pages. This feature will give us the chance to establish conditions that we can print on screen using other controls simply referring to the variable as parameter.
How to setup a “Variable” control in page?
First, we need to create a new page or select anyone previously created in the application.
Under page details, expand the “General Information” section
This control, unlike the previously created ones, needs to be setup on the “Variables” tab under the “General Information” section. Click on “New” button
A popup will be prompted to setup the “Variable” control
Fill in the name and select the type. This dropdown offers 2 options:
Local: In this case, the variable only can be used under the page where you are located.
Global: Variable can be used in all the pages from the Project’s application.
Click on “Data Binding” tab
In this section, we can establish default value for the variable. On the example, using the ampersand, we are going to make the value persists every time that the page is refreshed. Otherwise, we can set an specific value like “1” and this should be retrieved on loading screen.
Wayfast offers the ability to link the value from any dataset created in the project.
Turn to “Layout” tab
Set the “Order” to 0 and click on “Submit” button to save the changes.
New variable is displayed under “Variables” tab
How to include a variable under any other control?
Now that we have the variable generated, we need to take into consideration that this a “Local” variable type so it will be only available in this page.
Turn to “Controls” section and select “Label” control
Click on “New” button
Under the “General” tab, complete the required fields and focus on the “Value” field. Since this is a label, we can put a legend text and beside the fixed text, introduce the “Variable” using the ampersand like we explained in previous lessons regarding parameters. This reference will be retrieving the data from the variable.
Click on “Submit” button to save the changes and take a look about how this “Variable” control is combined with “Label” control using the preview screen.
How to set any control as variable?
We learnt how to create a variable from General Information, now we are going to set a control as a variable from its creation.
If we click on “New” related to “Label” control like we explained in previous steps, there’s a checkbox “Add as a variable” option
Checking this option, we can define the label as variable at the same time.
Recap
On this lesson, we learnt how to set a “Variable” control and establish a relationship with other controls like “Labels” that require an input value. In next lessons, we will explain how to use these variables through the Actions related to the project.