The following example illustrates using the SetVar element to set global scope for a variable. The second line returns the value set in the first line.
<SetVar Name="GlobalVar" Scope="Request">Value</SetVar>
...
<GetVar Name="GlobalVar">
In the following example, the first GetVar element returns "Value_2", and the second GetVar element returns "Value_1", because the SetVar element that contains "Value_2" applies only to children of the "Sample" element. "Value_2" goes out of scope after the closing "Sample" tag.
<SetVar Name="myVar">Value_1</SetVar>
<Sample>
<SetVar Name="myVar">Value_2</SetVar>
<GetVar Name="myVar"/>
</Sample>
<GetVar Name="myVar"/>
The following example evaluates whether a field is required and, if it is required, creates the red asterisk (*) that is displayed beside required fields in New or Edit forms and sets the HasRequired variable to TRUE.
<Switch>
<Expr>
<Property Select="Required"/>
</Expr>
<Case Value="TRUE">
<HTML><![CDATA[<font color=red> *</font>]]></HTML>
<SetVar Scope="Request" Name="HasRequired">TRUE</SetVar>
</Case>
</Switch>