Tag: If

The If function sets a branching condition in an XML automation script. The actions within the IF block are executed only if the condition is evaluated as true. The automation trace signals when an action is not executed due to its enclosing IF being evaluated as false

<IF target="Grid" test="VisibleRowsCount" mode="LessThan" value="5"> 
	<echo value="VISIBLE IN GRID < 2"/>

Detailed Description

Each of the three different IF action scenarios may be combined together within the same script block if needed, as each IF statement will be evaluated individually.

IF actions can also be nested:

NOTEALL IF actions will be tested unless they are nested and the higher IF condition does not take effect.

Tag Attributes

There are three main scenarios when employing IF actions; each one has a specific set of attributes possible:

1-Tag Attributes when Applicable to Loops

AttributesAttribute ValuesValue DescriptionComment




*or a user definable integer value

The position of the iteration within the Loop to which the the IF action will be connected - Required

The Index attribute is exclusive; it cannot be combined with other tag attributes.

2-Tag Attributes when Applicable to Tree or Grid Tests

AttributesAttribute ValuesValue Description
TargetApplicable Grid CodeTargets selection tree

Targets desired grid - Required




Sets what the IF action is "about"
A tree node or the number of selections in a selection tree, the number of selections, or the number of visible rows within a grid - Required







Declares comparison type - Required
ValueTrue / False

User definable integer

The value to use as a determinant - Required

3-Tag Attributes when Applicable to Variables

AttributesAttribute ValuesValue Description
TargetVarTriggers testing of the variables (must be set in SetVar actions) - Required
TestVariable nameThe variable to test - Required






Declares comparison type - Required
ValueUser defined stringThe value to use as a determinant - Required

With target "Question", all above parameters are ignored and the following are used:

A Message Box is displayed with two buttons (OK and Cancel). When the user clicks the OK button, IF is set as true and its sub-actions are executed. When the user clicks the Cancel button, IF is set as false and its sub-actions are ignored, its ELSE clause is executed if present.

AttributesValue Attribute
TitleN/A - Optional
MessageN/A - Required (But can be empty)
MessageExtendN/A - Optional
ButtonTextOkN/A - Optional (Defaults to OK")
ButtonTextCancelN/A - Optional (Defaults to "Cancel)
ImageSVG ID of the left-side image - Optional

Detailed Description

	<if Target="Question" image="question" Title="Filter groups?" Message="Apply filter" MessageExtended="from a list">
		<List name="O365GroupList" Action="SetVar" GType="Distribution list"/>
			<FilterFromList ListName="O365GroupList">
				<SetParam columnID="groupType" value="GType"/>
		<MsgBox image="thumb" Title="The groups" Message="Not filtered" MessageExtended="at all"/>


  • An IF can be nested within
  • Another IF
  • A LOOP
  • A modal action (action that happens within a modal dialog like Values, NotesIni etc)

Example Script - with the scanEZ tree

<Focus Target="Tree" Category="Profile Documents" Type="ColorProfile"/><!-- if focus tree element is not found, focus is set at tree root -- >
<If target="Tree" test="focusRoot" mode="equals" value="false"> <!-- if the tree focus is not at root level, ColorProfile was found -->
	<MySelection lastFocus="true">
		<Setparam Field="MySelectionName" Value="TheProfile1"/>
		<Setparam Field="TitleOptionType" Value="Formula"/>
		<Setparam Field="TitleOptionFormula" Value="@Implode(@DbName;"!!")"/>

Example Script - with a grid

<!-- do some filtering on the grid -->
	<If target="Grid" test="VisibleRowsCount" mode="LessThan" value="5"> <!-- if the main grid has less than 5 visible rows -->
<!-- do things -->

Loop tests

<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atapp.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest5.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest4.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest3.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest2.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest1.nsf"/>
	<loop list="MyList">
		<If index="last">
			<echo value="LOOP LAST"/>
		<If index="first">
			<echo value="LOOP FIRST"/>
		<If index="2">
			<echo value="LOOP 2"/>
		<If index="666">
			<echo value="VADE RETRO"/>
		<If index="4">
			<echo value="LOOP 4"/>

Grid & tree content tests

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ytriaAutomation Application="databaseEZ" ApplicationVersion="" Version="1.0">
	<echo mode="false"/>
	<Load Server="ytest-MD/TESTING" partial="true">
		<Load Database="AutoTest\lm_us_8.nsf" Select="True"/>
		<Load Database="AutoTest\lm_nab_8.nsf" Select="True"/>
		<Load Database="AutoTest\custinfo_s03.nsf" Select="True"/>
		<Load Database="websecuritystore.ntf" Select="True"/>
		<Load Database="YtriaLogFile-2013-03.nsf" Select="True"/>
	<IF target="tree" test="SelectionCount" mode="GreaterThan" value="3">
		<echo value="SELECTED IN TREE > 3"/>
	<IF target="tree" test="SelectionCount" mode="LessThan" value="10">
		<echo value="SELECTED IN TREE < 10"/>
	<IF target="tree" test="SelectionCount" mode="equals" value="5">
		<echo value="SELECTED IN TREE = 5"/>
	<IF target="tree" test="SelectionCount" mode="equals" value="100">
		<echo value="SELECTED IN TREE = 100"/>
	<IF target="grid" test="VisibleRowsCount" mode="GreaterThan" value="3">
		<echo value="VISIBLE IN GRID > 3"/>
	<IF target="grid" test="VisibleRowsCount" mode="LessThan" value="10">
		<echo value="VISIBLE IN GRID < 10"/>
	<IF target="grid" test="VisibleRowsCount" mode="equals" value="5">
		<echo value="VISIBLE IN GRID = 5"/>
	<IF target="grid" test="VisibleRowsCount" mode="equals" value="100">
		<echo value="VISIBLE IN GRID = 100"/>

List Existential Test

By default, the LIST test checks if the list exists:
- Mode defaults to "Exists" (no other mode value shall be accepted when Target is set to "List")
- Value defaults to "True"

<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atapp.nsf"/>
<List name="MyList" Action="Load" server="MAINR5/YTRIA" database="mail\atest5.nsf"/>
	<IF target="list" test ="MyList">
		<echo value="MyList exists! Yay"/>
	<IF target="list" test ="MyList" value="False">
		<echo value="MyList DOES NOT exist. Booo"/>
		<echo value="MyList still exists! YO"/>
	<IF target="list" test ="GhostList" value="False">
		<echo value="GhostList DOES NOT exist.."/>
		<echo value="GhostList exists!"/>