Concatenates a list or element to a list and returns the concatenated list.
listAppend(list, value [, delimiters, includeEmptyFields])
→ returns string
str.listAppend(value [, delimiters, includeEmptyFields])
,
false
true
false
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
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.