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 and Data Generator parameters.
  1. Open the User Registration flowchart.
  2. Click on Run and go to Advanced Run Settings
  3. Type the External Variable for firstname and lastname.
  4. Close Advanced Run Settings window and open Automate dialog
  5. On the Automate dialog, go to Entities tab and go to Data Generator sub-tab.
  6. Select the firstname attribute and set the prefix to {{var_firstname}}. The generated value can be seen in the Preview box.
  7. Select the lastname attribute and set the prefix to {{var_lastname}}. The generated value can be seen in the Preview 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.
  1. Go to Data Generator sub-tab and select email attribute
  2. Set the names to {{$this.firstname}}.{{$this.lastname}}. The generated value can be seen in the Preview box.
  3. infoThe syntax to use the generated value is:
    $this.attribute_name

Variable in UI Element

  1. In Entity tab of Automate dialog, the UI Element can be a variable reference. This variable value can be provided at runtime through Advanced Run Settings
  2. In Screen tab of Automate dialog, the UI Element can be a variable reference. This variable value can be provided at runtime through Advanced Run Settings

Variables in keyword step parameters

Example 3: Using Concatenation

  • The Variable Template for email generation can also be provided through the Edit Step dialog.
  1. Open the User Registration flowchart.
  2. On Automation dialog, under Keywords tab, select Enter $user details keyword.
  3. Double click on the step Set Value for Email Input to edit the step.
  4. Select the Element parameter type as JS Code and fill the UI Element in the textbox.
  5. [The UI Element can be taken from the Entities tab.]
  6. Select String type for the Value parameter.
  7. Type the concatenation string in the Value parameter textbox.
    {{$user.firstname}}.{{$user.lastname}}@example.com
  8. infoThere are three types of parameters: 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}}.
  9. Click on Update button.
  10. The step for email attribute gets updated with the new parameters.
  11. Click on Save Keyword
  12. Run the flow. It generates random firstname, lastname and generates the email by concatenating both along with the provided domain.

User-defined value

Example 4: Passing value at Runtime

  • The values for an attribute can be passed externally by providing key value.
  1. On the User Registration flowchart, open the Automate dialog.
  2. Click on Run button and go to Advanced Run Settings section.
  3. In the External Variables textbox, type email=simple@example.com.
    The format used here is key=value
  4. Go to the Edit Step dialog for email attribute
  5. Let theElement type as JS Code.
  6. Let the Value parameter type be String.
  7. Type {{$email}} in the Value parameter textbox.
  8. The step for email attribute gets updated with the new parameters.
  9. Click onRun. It will use the email same as defined under External Variables
concepts
    Use variable templates in keyword step parameters:
  • Using Concatenation
  • User defined value