Description
Gets the first element of a list.
Returns
The first element of a list. If the list is empty, returns an empty string.
History
ColdFusion (2018 release): Changed Parameter name includeEmptyValues to includeEmptyFields.
Category
Function syntax
ListFirst(list [, delimiters, includeEmptyFields ])
See also
ListGetAt, ListLast, ListQualify; Lists in Data types- Developing guide in the Developing ColdFusion Applications
Parameters
Parameter  | 
    Description  | 
   
|---|---|
includeEmptyFields  | 
    Optional. Set to yes to include empty values.  | 
   
list  | 
    A list or a variable that contains a list.  | 
   
delimiters  | 
    A string or a variable that contains one. Characters that separate list elements. The default value is comma. If this parameter contains more than one character, ColdFusion processes each occurrence of each character as a delimiter.  | 
   
Usage
ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements.
Example
<h3>ListFirst Example</h3> <!--- Find a list of users who wrote messages ---> <cfquery name = "GetMessageUser" datasource = "cfdocexamples"> SELECT Username, Subject, Posted FROMMessages </cfquery> <cfset temp = ValueList(GetMessageUser.Username)> <p>Before editing the list, it is:  <cfoutput>#ValueList(GetMessageUser.Username)#</cfoutput>. <p>(Users who posted more than once are listed more than once.) <!--- Show the first user in the list ---> <p>The first user in the list is: <cfoutput>#ListFirst(temp)#</cfoutput> <p>The rest of the list is: <cfoutput>#ListRest(temp)#</cfoutput>. <p>(Users who posted more than once are listed more than once.) <p>The last user in the list is: <cfoutput>#ListLast(temp)#</cfoutput>
<cfscript>
       myList="Tokyo,Bangkok,Jakarta,Manila,Bangalore,Shanghai";
       myFirst=ListFirst(myList);
       WriteOutput(myFirst); // Returns Tokyo
</cfscript>
		
	
Output
Tokyo