ListAppend
Appends an element to a list
Method Signature
ListAppend(list=[string], value=[string], delimiter=[string], includeEmptyFields=[boolean], multiCharacterDelimiter=[boolean])
Arguments
Argument
Type
Required
Description
Default
list
string
true
string list to filter entries from
value
string
true
The value to append
delimiter
string
false
string the list delimiter
,
includeEmptyFields
boolean
false
boolean whether to include empty fields in the returned result
false
multiCharacterDelimiter
boolean
false
boolean whether the delimiter is multi-character
true
Examples
Simple listAppend Example
Add 'foo' to the end of this list
oldList = "bar,bar2";
newList = listAppend( oldList, "foo" );
writeOutput( oldList & "-->" & newList );
Result: bar,bar2,foo
Simple listAppend Example with Delimiter
Add 'foo' to the end of this list using a custom delimiter
oldList = "bar,bar2";
newList = listAppend( oldList, "foo", "|" );
writeOutput( oldList & "-->" & newList );
Result: bar,bar2|foo
Simple listAppend Example with Empty Fields On
CF2018+ Add 'foo,,' to the end of this list using includeEmptyFields as true
oldList = "bar,bar2";
newList = listAppend( oldList, "foo,,", ",", true );
writeOutput( oldList & "-->" & newList );
Result: bar,bar2,foo,,
Simple listAppend Example with Empty Fields Off
CF2018+ Add 'foo' to the end of this list using includeEmptyFields as false
oldList = "bar,bar2";
newList = listAppend( oldList, "foo,,", ",", false );
writeOutput( oldList & "-->" & newList );
Result: bar,bar2,foo
Additional Examples
mylist = "one,two,three";
mynewlist = listAppend( mylist, "four" );
// Note that listAppend creates a new list. It doesn't update the existing list:
writeDump( mylist );
writeDump( mynewlist );
mylist = "foo";
mynewlist = listAppend( mylist, "bar", "|" );
writeDump( mynewlist );
Related
Last updated
Was this helpful?