Skip to main content
Skip table of contents

SetVarFromListValue: Set a variable from a value in a list

Tag: SetVarFromListValue

The SetVarFromListValue creates a variable (like SetVar) from a value in the list.

Detailed Description

All parameters are required:

XML
<SetVarFromListValue ListName="MyList" MyNewVar1="ParamNameFromMyListEntry" MyNewVar2="OtherParamNameFromMyListEntry"Where="YetAnotherParamNameFromMyListEntry" equals="xyz"/>


The first action in the list (according to order in the XML script) that matches the WHERE filter value sets the new variable(s). In the following example, the new variables MyNewVar1 and MyNewVar2are respectively set to YellowandBlack:

XML
<list name="ListOfVar2" action="Setvar" v1="Yellow" v2="Black" Number="43"/>/>
<list name="ListOfVar2" action="Setvar" v1="Red" v2="Blue" Number="3500"/>
<SetVarFromListValue ListName="ListOfVar2" MyNewVar1="v1" MyNewVar2="v2" Where="Number" GreaterThan="1"/>

Tag Attributes

Variable Name

Any unreserved name valid in XML. Reserved names are listed on: Variables

Variable ValueName of the parameter in the list to get the value from
WhereName of list entry parameter to test or Index
Filter ModeOne of...

Text filters:
  • Equals
  • Begins
  • NotBegins
  • NotEquals
  • Contains
  • NotContains
  • Ends
  • NotEnds
  • GreaterThan
  • GreaterOrEquals
  • LessThan
  • LessOrEquals


Number filters:

  • GreaterThan
  • GreaterOrEquals
  • LessThan
  • LessOrEquals


Date/Time: Not supported

Example: Begins="abcd"


Example Script

XML
<ytriaAutomation>
	<list name="ListOfVar" action="Setvar" v1="mugre" v2="chaise"/>
	<list name="ListOfVar" action="Setvar" v3="Roger" v4="Zer"/>
	<list name="ListOfVar" action="Setvar" v1="A" v2="B"/>
	<list name="ListOfVar" action="Setvar" v1="C" v2="D"/>
	<list name="ListOfVar" action="Setvar" v11="OK" v12="SAD" v3="Teeth" v4="Claw"/>
	<list name="ListOfVar" action="Setvar" v1="help" v2="pleh" v3="admin@OverHere.com" v4="www.ytria.com"/>
	<list name="ListOfVar" action="Setvar" v1="dog" v2="Leech" v3="Roger" v4="Zer"/>		
	<SetVarFromListValue ListName="ListOfVar" MyNewVar1="v3" MyNewVar2="v4" Where="v1" equals="dog"/>
	<SetVarFromListValue ListName="ListOfVar" MyNewVar3="v3" MyNewVar4="v4" Where="v1" equals="crocodile"/><!-- no param value march in list for v1 -->
	<SetVarFromListValue ListName="ListOfVar" MyNewVar5="VarDoesNotExist" Where="v1" notEquals="crocodile"/><!-- no param name march at all for VarDoesNotExist -->
	<list name="ListOfVar2" action="Setvar" v1="Red" v2="Blue" Number="42"/>
	<list name="ListOfVar2" action="Setvar" v1="Yellow" v2="Black" Number="999"/>/>
	<SetVarFromListValue ListName="ListOfVar2" MyNewVar6="v1" MyNewVar7="v2" Where="Number" GreaterThan="666"/>
	<echo value="MyNewVar1={%MyNewVar1%}"/>
	<echo value="MyNewVar2={%MyNewVar2%}"/>
	<echo value="MyNewVar3={%MyNewVar3%}"/>
	<echo value="MyNewVar4={%MyNewVar4%}"/>
	<echo value="MyNewVar5={%MyNewVar5%}"/>
	<echo value="MyNewVar6={%MyNewVar6%}"/>
</ytriaAutomation>



Using Index
Instead of using a variable name to fetch values from the list, the Index keyword can be used the Where clause and the value of the deisred index in the Equals clause.
Index starts at 1.

XML
<list name="ListOfVar" action="Setvar" v1="A1" v2="B1"/>
<list name="ListOfVar" action="Setvar" v1="A2" v2="B2"/>
<list name="ListOfVar" action="Setvar" v1="A3" v2="B3"/>
<SetVarFromListValue ListName="ListOfVar" MyNewVar1="v1" MyNewVar2="v2" Where="index" equals="3"/>
<echo value="MyNewVar1 = {%MyNewVar1%}"/>
<echo value="MyNewVar2 = {%MyNewVar2%}"/>


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.