|
Best of Support |
|
|
Formatting results of a multi-select List |
|
Issue
What do I need to do to format the values selected in a Dialog field which is a List type?
I'm having a tough time figuring out how I can get a reference to a List collection from the field.
Solution
Bart, I am assuming that your list type is a multi-select list. If it is a single-select list you can just access the value of the answer in the field. However multi-select lists are stored as a comma-separated value list (e.g.,"choice1","choice3","choice4").
In order to format values in the list there are a couple of options. The first thing you should do is convert that list answers to a collection using the task Lists.CSVToCol.
For example:
%[MyCollection=Lists.CSVToCol(MyDialog.MyField)]
Once you have it as a collection you then have a few choices. You can use ForEachBlock to iterate over the choices and format the results in a chart or table. Alternatively there are a couple of tasks that allow you to supply a collection and have GhostFill format the results with separators.
The one most relevant to a multi-select list would be Lists.FormatColField.
For example:
%[Result=Lists.FormatColField(MyCollection,"MyCollection", ", ", " and ")]
Result would contain a formatted list of the items selected from the multi-select list field, with each item separated by commas and the last item preceded by " and ".
Doug Simpson