Collection Controls


The Selection control supports five selection styles which determines their visual appearance and also determines whether a single item or multiple items can be selected.
- List - single
- DropList - single
- Radio - single
- Checkbox - multiple
- MultiList - multiple
To inspect a Selection control for yourself:
- In the Scripter Designer Script Resources section to the left, double click the Screen Step you wish to edit, to open it in Scripter Page Editor
- Drag a Selection control onto the Screen area
- With it selected, in the Properties list to the right, type a Name, e.g. myColours
- Close the Editor, saving your changes
- Drag the edited Screen Step on to the flow chart
- Double-click the step to edit in the Step Editor
The Step Editor gives access to our Selection control as follows:

Inputs
- myColours Items
- used to set a collection of input values, one per line
- may be populated with text, and campaign / script fields
- myColours -
- used to set the initial value when the screen is shown
- may be populated with text, or a campaign / script field
Outputs
- myColours Items
- used to capture the property output, one field per line
- may be populated with text, and campaign / script fields
- myColours
- used to capture the selected value of the control to a single script or campaign field.

The Checkbox and MultiList styles are visually very similar and it is a matter of preference as to which should be used.
For these styles, the data editor Inputs and Outputs tabs will show an additional entry named SelectedItems.
Inputs
- myColours SelectedItems
- used to preselect items when the screen is shown
- may be populated with text, and campaign / script fields, one per line.
Outputs
- myColours SelectedItems
- used to capture user selections from the control to multiple campaign / script fields, one per line.

From the agent's view, this works in the same way as the Selection control.
From a script writer and developer's perspective, it allows you to
- associate each item in the control with a key
- set the initial selected item(s) using keys/ values
- get the user selected item(s) using keys
The control is populated using XML in a fixed format, for both the Collection and Selection fields.

In the script, the following must be formatted on a single line.
For example:
<collection>
<entries>
<entry key="A1">Michigan</entry>
<entry key="B1">Vermont</entry>
<entry key="C1">Wisconsin</entry>
<entry key="C2">California</entry>
<entry key="D1">Alaska</entry>
</entries>
</collection>

In the script, the following must be formatted on a single line.
The Output always uses the key method to return the selected item(s):
<selection method="key">
<items>
<item>A1</item>
</items>
</selection>
The Input can use the key method (above) and also the value method (below):
<selection method="value">
<items>
<item>Michigan</item>
</items>
</selection>


The Data Query step can be used to take data from a database and return the data in an XML document. For usage details, see the Data Query control.
The database must be the same database as configured for the campaign's ODBC connection.
In order for a KeyedSelection control to make use of the returned result set, the shape of the data must be transformed, using the XSLT Transform step.

The Inputs and Outputs for the XSLT Transform step are:
Inputs
- Xslt Transform Document - see example below
- Xml Input Document - the Data Query step's Result Set output
Outputs
- Xml Output Document - used to store the result in a script variable

Using the Mobiles database, we want to show some surnames and use the postcode as a key. Supposing the query is this:
SELECT postcode, surname FROM Mobiles WHERE Contact_ID >= 10 AND Contact_ID <= 15;
...then the output from the Data Query step looks like this:

<collection>
<entries>
<entry surname="Elmes" postcode="Y" />
<entry surname="Follett" postcode="Q" />
<entry surname="Reddel" postcode="QNUU" />
<entry surname="Challinor" postcode="AC" />
<entry surname="Little" postcode="MAQNI" />
</entries>
</collection>
... using this transform

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"></xsl:output>
<xsl:template match="/">
<collection>
<entries>
<xsl:for-each select="collection/entries/entry">
<entry>
<xsl:attribute name="key">
<xsl:value-of select="@postcode"></xsl:value-of>
</xsl:attribute>
<!-- append the attribute to element content-->
<xsl:value-of select="@surname"></xsl:value-of>
</entry>
</xsl:for-each>
</entries>
</collection>
</xsl:template>
</xsl:stylesheet>
... the transformed output is this:

<collection>
<entries>
<entry key="Y">Elmes</entry>
<entry key="Q">Follett</entry>
<entry key="QNUU">Reddel</entry>
<entry key="AC">Challinor</entry>
<entry key="MAQNI">Little</entry>
</entries>
</collection>

The same operation may be performed using the Execute SQL Select step instead of the Data Query step.
Using a different SELECT statement in this case, the output from the Execute SQL Select step would look like this:

<QueryResult>
<Row>
<Contact_ID>10</Contact_ID>
<Surname>Elmes</Surname>
</Row>
<Row>
<Contact_ID>11</Contact_ID>
<Surname>Follet</Surname>
</Row>
<Row>
<Contact_ID>12</Contact_ID>
<Surname>Reddel</Surname>
</Row>
<Row>
<Contact_ID>13</Contact_ID>
<Surname>Challinor</Surname>
</Row>
<Row>
<Contact_ID>14</Contact_ID>
<Surname>Little</Surname>
</Row>
</QueryResult>
... using this transform

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"></xsl:output>
<xsl:template match="/">
<collection>
<entries>
<xsl:for-each select="QueryResult/Row">
<entry>
<xsl:attribute name="key">
<xsl:value-of select="Contact_ID"></xsl:value-of>
</xsl:attribute>
<!-- append the attribute to element content-->
<xsl:value-of select="Surname"></xsl:value-of>
</entry>
</xsl:for-each>
</entries>
</collection>
</xsl:template>
</xsl:stylesheet>
... the transformed output is this:

<collection>
<entries>
<entry key="10">Elmes</entry>
<entry key="11">Follett</entry>
<entry key="12">Reddel</entry>
<entry key="13">Challinor</entry>
<entry key="14">Little</entry>
</entries>
</collection>