• Documentation
  • Tutorials
  • Blogs
  • Product

What's on this Page

  • Variable types
  • Declaring variables in Plan
    • Variables in Set control
    • Variables in Parameters
    • Variables in Execution parameters
  • Accessing variables
  • Step
  • User guide
  • Plans
  • Using variables in Plans
Categories: USER GUIDE PLANS
This article references one of our previous releases, click here to go to our latest version instead.

Using variables in Plans

Variables are used throughout plans to pass information from one node to another, or to store the result of a dynamic computation.

Variable types

Similar to any programming language, Step supports the use of variables in Plans. The variables declared and used in a Plan are called Plan variables. A Plan variable is a container that stores a data value under a specific name.

Like in classical programming languages, Step supports the following types of variables:

  • String: stores text (Default type of variables in Step)
  • Number: can be integer, long, float, or double
  • Boolean: stores values with two states: true or false
  • Complex Java objects: lets you define expressions for performing advanced data handling

When passing or setting a variable into the value field of a control or Keyword input, Groovy execution will be required for numbers, booleans, and complex Java objects. The Groovy toggle is a powerful feature in Step that lets you add dynamic behavior to a plan without modifying your Keywords.

Declaring variables in Plan

In Step, you have different ways to declare Plan variables:

  • Using Set control: the most common way to declare a Plan Variable is to use the dedicated Set control in your Plan
  • Using Parameters: Parameters declared in the web interface under Parameters are made available to the Plan as Variables
  • Using Execution Parameters: Execution Parameters selected at the start of execution (Environment, etc) are also made available to the Plan as Variable. See Executing a Plan

Variables in Set control

    Using the Visual Plan editor, you can use the Set control as follow to declare a variable:

    This would declare a variable called “myVar” as String and set its value to “This is a string value”.

    The dynamic field button: Without activating the dynamic field button of the “value” field, the input value is interpreted as String. However, activating the dynamic field interprets the input value as a Groovy expression; and the result of the evaluation is set to “myVar” variable. And thus, lets you declare other primitives like integer, long, boolean, or complex object.

    To declare a variable as an integer, toggle the dynamic field button as follow:

    Using the plain text editor, you can use the Set control as follows to declare a variable:

    Set city="Basel"
    MyKeyword Parameter1="Welcome to ${city}"
    Set City="Bern"
    MyKeyword Parameter1="Welcome to ${city}"
    In this case the variable "city" will be declared as String.

    Similar to the Visual Plan Editor, you can also use Groovy expressions in the declaration of variables .

    Set birthyear=2006
    Set age=2019-birthday

    In this case, the variable “birthyear” will be declared as integer. The variable “age” will also be declared a integer as the result of the operation “2019-birthday”

    Find out about all possibilities in our Javadocs

    See also Controls

    Variables scope: A variable defined using the Set control is limited to the block where it is defined.
    For example, if a variable is defined inside the root node, it will be accessible to the subsequent nodes and their child nodes. However, if a variable is defined inside a child node, it will not be available to the ancestors and siblings of that child node.

    Variables in Parameters

    Parameters declared in the web interface through the Parameters page are automatically declared by Step as variables at the beginning of the execution and can thus be accessed in the Plan like any other Plan variable.

    Variables in Execution parameters

    The parameters selected for the execution of a Plan (like “Environment”) are called Execution parameters. These Execution Parameters are also declared by Step as Plan variables at the beginning of the execution and can be accessed in the Plan like any other Plan variable.

    Accessing variables

    Variables can be accessed practically everywhere in Plans and can also be passed to Keywords.

      Using the Visual Plan Editor, you can access previously defined variables in every field that has the dynamic field button as shown in the following screenshot. The variables are available as binding in Groovy expressions.

      In this example, we pass the content of the variable “myVar” to the first parameter of the Keyword “My Keyword”.

      Using the plain text syntax you can use the following syntax to access the content of previously declared variables:

      Set birthyear=2013
      Set age=2019-birthyear
      Set city="Lucerne"
      
      MyKeyword Parameter1="I was born in ${city} in ${birthyear} and I am now ${age} years old"

      This would call the Keyword “MyKeyword” and set the value of variable “Parameter1” to “I was born in Lucerne in 2013 and I am now 6 years old”

      Find out about all possibilities in our Javadocs

      See Also

      • Controls
      • Calling Keywords in Plans
      • Java Plan API
      • Parameters
      • Plain text plans
      • Home
      • Whats new?
      • Set up
      • Administration
      • SaaS guide
      • User guide
        • Keywords
        • Plans
          • Keyword calls
          • Controls
          • Plan modularity
          • Variables
          • Visual Plan editor
          • Plain text plans
          • Java Plan API
        • Executions
        • Agent provisioning
        • Alerting and notifications
        • Bookmarks
        • Incidents
        • Parameters
        • Analytics
        • Monitoring
        • Schedules
        • Event Broker Monitor
        • Import/Export entities
        • User account
        • Versioning
      • Developer guide
      • DevOps
      • Plugins
      • Libraries
      Step Logo
        • Documentation
        • Tutorials
        • Blogs
        • Product
        • Home
        • Whats new?
        • Set up
        • Administration
        • SaaS guide
        • User guide
          • Keywords
          • Plans
            • Keyword calls
            • Controls
            • Plan modularity
            • Variables
            • Visual Plan editor
            • Plain text plans
            • Java Plan API
          • Executions
          • Agent provisioning
          • Alerting and notifications
          • Bookmarks
          • Incidents
          • Parameters
          • Analytics
          • Monitoring
          • Schedules
          • Event Broker Monitor
          • Import/Export entities
          • User account
          • Versioning
        • Developer guide
        • DevOps
        • Plugins
        • Libraries