Skip to main content
Skip table of contents

Combine: Combine two lists into another list

Tag: Combine

The Combine function creates a list either from the common elements or from the different elements in two source lists.

Detailed Description

From two source lists List1 and List2, a third target list that contains a subset of the two sources can be easily created.

If the new list already exists, it is replaced by the result of Combine.

The target list is populated either with the common elements in both source lists, or with the elements found in one list but not the other.

The list element comparison is performed on a single list element parameter. Its name is assigned to the EQUALS parameter of Combine. For example, if both source list elements contain a parameter named V1, EQUALS=”V1” is set in Combine so that the value of V1 is used in each element from the source lists to select the ones to copy to the target list.

Tag Attributes

Attributes

Value Description

Source

Any string to ID the name of the first list (required)

Source2

Any string to ID the name of the second list (required)

Target

Any string to ID the name of the target list (required)

Equals

Name of parameter to use for a source list subset selection (required)

Mode

List combination mode (required), select one among:

  • Both: the target shall contain all elements from the source lists that are present in both lists for the parameter set with Equals

  • Extra: the target list shall contain elements from Source2 that are not found in Source for the parameter set with Equals

Example Script

XML
<ytriaAutomation>

    <SplitIntoSetVarList ListName="sourceList1" separator=":" var1="v1:v2:v3:v4"/>
    <SplitIntoSetVarList ListName="sourceList2" separator=":" var1="v1:v5:v6:v2"/>
	<Combine target="combinedList" source="sourceList1" source2="sourceList2" equals="var1" mode="both"/>	
	<Loop list="combinedList">
		<ExecuteListAction/>
	</Loop>	
	<Combine target="combinedList" source="sourceList1" source2="sourceList2" equals="var1" mode="extra"/>	
	<Loop list="combinedList">
		<ExecuteListAction/>
	</Loop>	
</ytriaAutomation>

In this example, we create two lists sourceList1 and sourceList2, whose elements are “SetVar var1=…”.

Then we combine them into combinedList through var1.

First we create a list of common entries, i.e. combinedList contains elements of sourceList1 and sourceList2 that have values for var1 found in sourceList1 and sourceList2.

Then we re-create combinedList with the values for var1 that are found in sourceList2 but not in sourceList1.

JavaScript errors detected

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

If this problem persists, please contact our support.