1. Home
  2. Using Warewolf
  3. How to work with data and variables in Warewolf

How to work with data and variables in Warewolf

Using data and variables in Warewolf is easy. We have designed Warewolf to be as simple and easy to use as possible, and no simpler (thanks for that, Einstein).

To achieve this, we made Warewolf take care of data typing (integers, strings, dates etc.) for you. You don’t need to describe the data you are going to use; you just go ahead and use it. Warewolf categorizes your variable types in the background for performance gains and optimizations.

This allows you to use variables on the fly as you program your service simply by using the variable notation: two open square braces [[alphanumeric variable name followed by two closing square braces]] resulting in something that looks like this: [[MyVar]]

So how do you work with data and variables in Warewolf?

There are four easy ways to get data into your variables.

 Firstly by assigning data using the Assign tool:
  1.  Drag an Assign tool onto the design surface from the toolbox and connect it at the step you want the variable to be set: Assign Tool Image - Showing Variable and Value
  2. In the left hand field Enter [[MyVar]] and in the right hand field enter 123. This will assign the variable MyVar = 123:Assign Tool - Variable Used in Warewolf
  3. Most input or value fields (like the right hand field) can take a combination of data AND variables. The value of [[FullName]] below will be Simpson, Bart:Assign Tool- Showing Variables in Warewolf
 The second way of getting data into variables is to use a variable in the Result field of a tool:
  1. Drag a tool onto the design surface and connect it at the step you want the tool to execute at. We will use the Write File Tool:Write File tool - Used in Warewolf
  2. Put in the File Name and the Contents you want written to the file. Put the name of the variable that you want the Result data to go into. In this case [[DailyReportWriteSuccess]] (Double Click the body of the tool for its large view):Write File - Result showing in Warewolf
  3. The value of [[DailyReportWriteSuccess]] = Success
The third way of getting data into a variable is to pass it in as an input to the service:
  1. Drag the tool on that needs to use the input value and configure it as if the data was there: EXAMPLE: A calculate tool using a variable [[Num]] multiplied by itself and putting the product into a new variable [[NumSquared]] Calculate - Syntax in Warewolf
  2. In the Variable window, set the Num variable to an Input by checking the Input box: Variables used in Warewolf showing Input and output
  3. When this service is executed on its URL, pass the value of Num in the query string: image of query string showing variable in Warewolf ESB
The fourth way to get data into a variable is to output it from another service or connector:
  1. Drag the Hello World service from the Explorer onto a new design surface: Hello World - Input Data and Output data
  2. The Hello World workflow has Message defined as an Output. When you drop services and connectors on the design surface they automatically create variable names for their input and output, but you can change them to anything you want/anything relevant. Hello World - Depicting Name and Message
  3. The value of [[Greeting]] = Hello Barney.

 

It’s as simple as that. You can read more about variables in the knowledge base.

Not what you were looking for? Ask our expert users in the Community Forum.

FacebookTwitterLinkedInGoogle+Email
Updated on July 19, 2017

Was this article helpful?

Related Articles

Enjoying Warewolf?

Write a review on G2 Crowd
Stars