How to Initialize a Variable?

You are currently viewing How to Initialize a Variable?

Initializing a variable means that we are specifying an initial value to assign to it before it can be used. If no values are chosen to initialize with, it will contain nothing.

Sometimes variables need to be initialized before used. This is most common for Data Collections like Arrays, DataTables and Lists. Initializing variables is optional for data types like Strings, Integers and Booleans.

There are multiple ways to initialize variables which include:

Assign as New

Assigning variables as new allow you to start with a clean slate. The variable has been initialized and when called will return nothing. Now you can add data values during the automation.
  • List
  • DataTable
  • Array

Assign as Clone

Initializing variables using this method will clone another variable and use its schema or format to create the new variable you wish to create. Only data types that include the clone method can be assigned as a clone.
  • DataTable

Build DataTable

DataTables can also be initialized using the Build Data Table activity. This activity allows you to create the schema and format of DataTable you wish to create using a helpful wizard.
  • DataTable

Conclusion...

In conclusion, here’s a few things to remember about Initializing Variables:
  • Initializing variables is primarily used for data collections, but can also be used for any data type.
  • You can use the assign activity to initialize variables.
  • The Build DataTable activity provides a helpful wizard to design a Datatable to intialize.