Variable Templates
abstract
Variable Templates allow the user to reference variable values in string parameters. During execution of the flow, the referenced variable will be resolved and replaced with its current value. This allows the user to focus on the form of input, instead of worrying about correct syntax for concatenating variables in parameters.
infoThe variable values may come from external parameters, entity attributes, variables defined in raw scripts or variables created from Store steps and Rest UI.
infoThe following examples use User Registration flowchart
steps
Variables in Data Generator
Example 1: Generating name
- Values of a field can be generated with a combination of some variable values provided at
RUN
andData Generator
parameters.
- Open the
User Registration
flowchart. - Click on
Run
and go toAdvanced Run Settings
- Type the
External Variable
for firstname and lastname. - Close
Advanced Run Settings
window and openAutomate
dialog - On the
Automate
dialog, go toEntities
tab and go toData Generator
sub-tab. - Select the
firstname
attribute and set theprefix
to{{var_firstname}}
. The generated value can be seen in thePreview
box. - Select the
lastname
attribute and set theprefix
to{{var_lastname}}
. The generated value can be seen in thePreview
box.
infoBoth firstname and lastname have used the
External Variable
passed through the Run Settings
dialog.Example 2: Generating email based on other values
infoEmails can be generated randomly through the
Data Generator
using Timestamp
. The user may need to generate the email based on other details. For example, an email can be in the format firstname.lastname@domain_name
.- Values of a field can be generated with a combination of values already generated through
Data Generator
.
- Go to
Data Generator
sub-tab and selectemail
attribute - Set the
names
to{{$this.firstname}}.{{$this.lastname}}
. The generated value can be seen in thePreview
box.
infoThe syntax to use the generated value is:
$this.attribute_name
Variable in UI Element
- In
Entity
tab ofAutomate
dialog, theUI Element
can be a variable reference. This variable value can be provided at runtime throughAdvanced Run Settings
- In
Screen
tab ofAutomate
dialog, theUI Element
can be a variable reference. This variable value can be provided at runtime throughAdvanced Run Settings
Variables in keyword step parameters
Example 3: Using Concatenation
- The
Variable Template
for email generation can also be provided through theEdit Step
dialog.
- Open the
User Registration
flowchart. - On
Automation
dialog, underKeywords
tab, selectEnter $user details
keyword. - Double click on the step
Set Value
forEmail Input
to edit the step. - Select the
Element
parameter type asJS Code
and fill theUI Element
in the textbox.
[The - Select
String
type for theValue
parameter. - Type the concatenation string in the
Value
parameter textbox.
{{$user.firstname}}.{{$user.lastname}}@example.com
- Click on
Update
button. - The step for
email
attribute gets updated with the new parameters. - Click on
Save Keyword
- Run the flow. It generates random
firstname
,lastname
and generates theemail
by concatenating both along with the provided domain.
UI Element
can be taken from the Entities
tab.]
infoThere are three types of parameters:
Variable templates can only be used in
The variables have to be inside double curly braces and preceding with a '$' sign, like:
Reference
, String
and JS Code
.Variable templates can only be used in
String
parameters.The variables have to be inside double curly braces and preceding with a '$' sign, like:
{{$variable_name}}
.
User-defined value
Example 4: Passing value at Runtime
- The values for an attribute can be passed externally by providing
key value
.
-
On the
User Registration
flowchart, open theAutomate
dialog. - Click on
Run
button and go toAdvanced Run Settings
section. - In the
External Variables
textbox, typeemail=simple@example.com
.
The format used here iskey=value
- Go to the
Edit Step
dialog foremail
attribute - Let the
Element
type asJS Code
. - Let the
Value
parameter type beString
. - Type
{{$email}}
in theValue
parameter textbox.
- The step for
email
attribute gets updated with the new parameters. - Click on
Run
. It will use theemail
same as defined underExternal Variables
concepts
-
Use variable templates in keyword step parameters:
- Using Concatenation
- User defined value