listAppend

Concatenates a list or element to a list and returns the concatenated list.

listAppend(list, value [, delimiters, includeEmptyFields]) → returns string

Member Function Syntax

str.listAppend(value [, delimiters, includeEmptyFields])

listAppend Argument Reference

list string
Required

A list or variable with the list.

value string
Required

An element or a list of elements.

delimiters string
Default: ,

A string or variable with a character that separates list elements.

includeEmptyFields boolean
Default: false

CF 2018+ Set to true to append blank values to the list.
Values:
  • true
  • false

Examples sample code invoking the listAppend function

Add 'foo' to the end of this list

oldList = "bar,bar2";
newList = listAppend(oldList, "foo");
writeOutput(oldList & "-->" & newList);

Expected Result: bar,bar2,foo

Add 'foo' to the end of this list using a custom delimiter

oldList = "bar,bar2";
newList = listAppend(oldList, "foo", "|");
writeOutput(oldList & "-->" & newList);

Expected Result: bar,bar2|foo

CF 2018+ Add 'foo,,' to the end of this list using includeEmptyFields as true

oldList = "bar,bar2";
newList = listAppend(oldList, "foo,,", ",", true);
writeOutput(oldList & "-->" & newList);

Expected Result: bar,bar2,foo,,

CF 2018+ Add 'foo' to the end of this list using includeEmptyFields as false

oldList = "bar,bar2";
newList = listAppend(oldList, "foo,,", ",", false);
writeOutput(oldList & "-->" & newList);

Expected Result: bar,bar2,foo


Fork me on GitHub