Set Variable

From PresenceWiki
Jump to: navigation, search

The Set Variable Node stores a value against a Variable Name for use in the current Task, or other Tasks, depending on the Scope. For more information on variable scopes, see the Variables page.

In the most simple scenario the value will consist of a literal - for example, "Fred" or 3.1416.

A Variable value may also reference another Presence variable, a Data Table column value, or a function call - or any combination of these. The following are all examples of valid values for a variable:

  • Apple
  • &upperCase{"hello world"}
  • &lowerCase{"Hello ${name}"}
  • &eval{"pow((${radius}*${pi}), 2)"}
  • Current record is :var{RECORD_ID}

The last of these examples poses an interesting question - that is, what happens when a Data Table reference is set as the value of a variable? Given that Presence uses implicit iteration (see Data Table discussion page) one might expect all potential values to be included in the result. However, this is not necessarily the case.

Variable names can also contain column references. For example, the following is a perfectly valid variable name:


The value may point to another column, for example:


This now means that for every distinct value of ROWID in our Data Table we now have a variable set whose value corresponds to the contents of the HOUSE_NUMBER column of the same row. See Presence Context#Compound Variables for more information.

However, if no column reference exists in the variable name there can only be one variable created, and one value. The value will be taken from the first record in the current Data Table.

Task Elements > Variable Nodes > Set Variable

See Also: Require Variable(s) | Set Variable | Multiple Variable Setter | Variable Unlocker