Ytria logo DOCUMENTATION
⚠ This page requires javascript enabled in browser
Automation / All products Automation / Global Actions / Logic Actions

 

Tag: IF

The IF action lets you set branching conditions in a script. The automation trace will signal when an action is not executed due to its IF condition being evaluated as False.

<IF target="Grid" test="VisibleRowsCount" mode="LessThan" value="5">

    <echo value="VISIBLE IN GRID &lt; 2"/>
</IF>


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 ValueValue DescriptionComment
IndexFirst

Last

Other

Unique

*or a user definable integer value

The position of the iteration within the Loop to which the the IF action will be connected.Mandatory

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



2-Tag Attributes when Applicable to Tree or Grid Tests

AttributesAttribute ValueValue DescriptionComment
TargetApplicable Grid CodeTargets selection tree

Targets desired grid

Mandatory
TestFocusRoot

SelectionCount

VisibleRowsCount

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.
Mandatory
ModeEquals

NotEquals

GreaterThan

GreaterorEquals

LessThan

LessOrEquals

Declares comparison typeMandatory
ValueTrue/False

User definable integer

The value to use as a determinantMandatory


3-Tag Attributes when Applicable to Variables

AttributesAttribute ValueValue DescriptionComment
TargetVarTriggers testing of the variables (must be set in SetVar actions)Mandatory
TestVariable nameThe variable to testMandatory
ModeEquals

NotEquals

GreaterThan

GreaterorEquals

LessThan

LessOrEquals

Declares comparison typeMandatory
ValueUser defined stringThe value to use as a determinantMandatory


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.

Example Script

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ytriaAutomation Application="databaseEZ" ApplicationVersion="16.5" Console="True">
<echo mode="false"/>
<Load Server="ACME01/ACME" partial="true">
<Load Database="Mailtest.nsf" Select="True"/>
<Load Database="Mailtest2.nsf" Select="True"/>
<Load Database="Mailtest3.nsf" Select="True"/>
</Load>
<IF target="tree" test="SelectionCount" mode="GreaterOrEquals" value="3">
<echo value="AT LEAST 3 DATABASES SELECTED IN TREE"/>
</IF>
<IF target="grid" test="VisibleRowsCount" mode="LessThan" value="3">
<IF target="grid" test="VisibleRowsCount" mode="LessThanOrEquals" value="2">
<echo value="LESS THAN 3 DATABASES VISIBLE IN THE GRID"/>
</IF>
<IF target="grid" test="VisibleRowsCount" mode="Equals" value="0">
<echo value="NO DATABASES LOADED – CHECK DATABASE INFORMATION"/>
</IF>
</IF>
</ytriaAutomation>

In the script above, three databases ("Mailtest.nsf", "Mailtest2.nsf", and "Mailtest3.nsf") will be loaded into the database selection tree and selected. The first of the four IFconditions in the script declares that if the number of databases selected in the tree is greater than or equal to "3", the Echo action will trigger the text "AT LEAST 3 DATABASES SELECTED IN TREE" to be displayed in the Automation Console. The second IF condition will be evaluated, and if the test finds that less than "3" databases are selected, the nested IF conditions will apply. The nested IF conditions declare that if the number of databases selected in the tree is less than or equal to "2", the Echo action will trigger the text "LESS THAN 3 DATABASES ARE VISIBLE IN THE GRID" to be displayed in the console. The last of the IF conditions states that if the number of databases visible in the grid is equal to "0", the Echo action will trigger the text "NO DATABASES LOADED – CHECK DATABASE INFORMATION" to be displayed in the console.