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
RUNandData Generatorparameters.
- Open the
User Registrationflowchart. - Click on
Runand go toAdvanced Run Settings - Type the
External Variablefor firstname and lastname. - Close
Advanced Run Settingswindow and openAutomatedialog - On the
Automatedialog, go toEntitiestab and go toData Generatorsub-tab. - Select the
firstnameattribute and set theprefixto{{var_firstname}}. The generated value can be seen in thePreviewbox. - Select the
lastnameattribute and set theprefixto{{var_lastname}}. The generated value can be seen in thePreviewbox.
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 Generatorsub-tab and selectemailattribute - Set the
namesto{{$this.firstname}}.{{$this.lastname}}. The generated value can be seen in thePreviewbox.
infoThe syntax to use the generated value is:
$this.attribute_nameVariable in UI Element
- In
Entitytab ofAutomatedialog, theUI Elementcan be a variable reference. This variable value can be provided at runtime throughAdvanced Run Settings - In
Screentab ofAutomatedialog, theUI Elementcan 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 Templatefor email generation can also be provided through theEdit Stepdialog.
- Open the
User Registrationflowchart. - On
Automationdialog, underKeywordstab, selectEnter $user detailskeyword. - Double click on the step
Set ValueforEmail Inputto edit the step. - Select the
Elementparameter type asJS Codeand fill theUI Elementin the textbox.
[The - Select
Stringtype for theValueparameter. - Type the concatenation string in the
Valueparameter textbox.
{{$user.firstname}}.{{$user.lastname}}@example.com
- Click on
Updatebutton. - The step for
emailattribute gets updated with the new parameters.
- Click on
Save Keyword - Run the flow. It generates random
firstname,lastnameand generates theemailby 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}}.
Example 4: Using in REST API Call
- The
Variable TemplateforREST API Callcan also be provided through theBodyasRaw.
- Open the
User Registrationflowchart. - On
Automationdialog, underKeywordstab, selectEnter $user detailskeyword. - Add step
REST API CallwithBodyas raw. - Fill up the relevant field with all required information.
- Select
BodyasRaw. - Pass
Variable TemplateinRawtextarea.
{ "title":"{{$post.name}}", "dueDate":"2024-12-18T12:51:54.969Z", "completed":{{$post.comp}} }
- without quotes
- Use this method when a
Variable Templatevalue is required as non string"completed":{{$post.comp}}// here {{$post.comp}} contain a boolean value. - within quotes
- Use this technique exclusively in cases where a
Variable Templatevalue is required as string"title":"{{$post.name}}"// here server accept only value as a string. - Click on
Updatebutton. - The
REST API Callstep'sbodyis updated withvariable template. - Click on
Save Keyword - Run the flow. It will send a
REST API Callwith theBodyvalue asVariable Templatevalue.
infoThere are two ways to pass
Variable Template in Raw textareaUser-defined value
Example 5: Passing value at Runtime
- The values for an attribute can be passed externally by providing
key value.
-
On the
User Registrationflowchart, open theAutomatedialog. - Click on
Runbutton and go toAdvanced Run Settingssection. - In the
External Variablestextbox, typeemail=simple@example.com.
The format used here iskey=value
- Go to the
Edit Stepdialog foremailattribute - Let the
Elementtype asJS Code. - Let the
Valueparameter type beString. - Type
{{$email}}in theValueparameter textbox.
- The step for
emailattribute gets updated with the new parameters.
- Click on
Run. It will use theemailsame as defined underExternal Variables
concepts
-
Use variable templates in keyword step parameters:
- Using Concatenation
- User defined value