The Copy function adds the content of a list to another list. It can also be used to trim a list to a subset of its elements.
A list can be copied partially or entirely to another list.
The target list is created if it does not exist. If it does exist before the copy, its content is not replaced but added to.
To copy an entire list, only the names of the source and target lists need to be set.
To copy a subset of a list, the WHERE parameter and a mode of comparison need to be set.
WHERE sets which parameter is to be used for the match, the comparison mode sets how the comparison is performed to select the elements to copy.
Any string to ID the name (required)
Regular action name (required)
Name of parameter to use for a source list subset selection (optional)
(where comparison mode)
If the Where attribute is used, a comparison mode is required, one of:
IsIn and IsNotIn work with a colon separated array of values:
<Copy source="sourceList" target="newTargetList" where="var2" IsIn="a:b:c"/>
Any element from sourceList whose var2 attribute equals either a, b or c is selected and copied into newTargetList.
When using Where, elements from the source list that do not have an attribute by the name set in the Where attribute are not copied.
<ytriaAutomation> <SplitIntoSetVarList ListName="sourceList" separator=":" var1="v1:v2:v3:v4" var2="42:999:chaise"/> <SplitIntoSetVarList ListName="targetList" separator=":" var1="v1:v5:v6:v1" var2="43:steak:oil:44"/> <Copy source="sourceList" target="targetList"/> <Loop list="targetList"> <ExecuteListAction/> </Loop> <Copy source="targetList" target="newTargetList" where="var2" greaterThan="42"/> <Loop list="newTargetList"> <ExecuteListAction/> </Loop> </ytriaAutomation>
In this example:
Two lists are created (sourceList and targetList)
sourceList is entirely copied to targetList. The content of sourceList is added to the content of targetList.
targetList is partially copied to a new list that does not exist yet, newTargetList. The Where attribute restricts the copy operation to elements in targetList whose values of attribute var2 have a value greater than 42.
The console output for this script: