This video explains how we use and refer to data and variables in Warewolf. Understanding the Warewolf syntax is key to getting the most value out of Warewolf.
There are two kinds of data in Warewolf:
- First we have Scalar variables: An individual piece of data, always shown in double square brackets [[VariableName]]
- And we have Recordsets: A Recordset is a data structure that consists of a group of database records. In Warewolf we show recordsets as: [[Recordset(n).Field]] where n refers to the index of the recordset
A Recordset may look something like this, where the Fields are Name, SecName and Surname. The indexes are the row number: 1 or 2.
The Recordset data above can be given a collective name, such as People. If we represented this as Recordsets inside Warewolf, we would have the following:
Recordsets are shown in the Variables list and can also be selected as inputs or outputs.
- As Input: Behaves exactly like a scalar variable: The value of Field in row/record 1 will be used. So, from the table above [[People(1).Surname]] will be Simpson
- As Output: Behaves exactly like a scalar variable. The value of Field in row/record 1 will be the value of the result. If we were to assign the result of something (say Mike) to [[People(2).SecName]] then [[People(2).SecName]] would now be Mike and not Oscar.
This recordset row has no index specified
- As Input: Assumes the last index in a recordset. The value of Field at the last index, so you don’t have to track it. This works well for reading the last row in a recordset. [[People().Name]] will be Bart.
- As Output: Assumes a new Index. Appends a new record to the end of the recordset. If the result we wanted to assign was Lisa, we could use the Assign tool: [[People().Name]] = Lisa. This would create a new index (3) with a Name = Lisa and the remaining fields blank.
[[Recordset(*).Field]] : This will use every row in the Recordset
As Input: Will execute each and every index in the Recordset.
- As Output: Will write a result to each and every index starting at 1, until there are no more results.
[[Recordset()]] – no Field
- As Input: Used in some tools to process specific recordsets.
- As Output: Never.
To move a Recordset from one workflow to another workflow simply map it in using * as the index, for example:
[[People(*).Name]] will use every index of Name. In the Example, we are mapping 2 records in the [[People()]] recordset to the [[Family()]] recordset.
Also, illustrated here is that by placing two variables next to each other in an assignment, they are joined into one variable.
The new Recordset, called Family, will look like this, where the Fields are FName, SName and Town.
|1||Marjorie Ann Agnes||Simpson||Springfield, Oregon|
|2||Bart Oscar||Simpson||Springfield, Oregon|
Database, Web Service and Plugins endpoints are outside the control of Warewolf. If you enter a * we will cram all the info into that input field. If you want to shape the data first, use the JSON or XML tool.