Whatever message this page gives is out now! Go check it out!

ValueList

Last update:
May 18, 2026

Description

Inserts a delimiter between each value in an executed query. ColdFusion does not evaluate the arguments.

Returns

A delimited list of the values of each record returned from an executed query.

Category

Function syntax

ValueList(queryColumn [, delimiter ])

History

ColdFusion (2018 release): Introduced named parameters.

See also

Parameters

Parameter
Description
queryColumn
Name of an executed query and column. Separate query name and column name with a period.
delimiter
A delimiter character to separate column data items. The default value is comma (,).

Example

<cfscript>
    myQuery=queryNew("id,title", "integer,varchar",
    [ {"id":1,"title":"Iron Maiden"}, 
      {"id":2,"title":"Judas Priest"},
      {"id":3,"title":"Black Sabbath"},
      {"id":4,"title":"Deep Purple"},
      {"id":5,"title":"Rolling Stones"}
    ]);
    valueListTitle=ValueList(myQuery.title)
    writeOutput(valueListTitle)
</cfscript>
Output
Iron Maiden,Judas Priest,Black Sabbath,Deep Purple,Rolling Stones

Real-world use cases of the ValueList function

Email marketing- Customer mailing lists

A marketing department needs to create targeted email campaigns for different customer segments. The CRM system stores thousands of customer emails in a relational database, and marketing teams need to extract these emails into formats compatible with bulk email systems and campaign management platforms.
How it helps:
  • Direct conversion from CRM queries to email-ready lists
  • Multiple delimiter options for different email platforms
  • Filter and target specific customer groups dynamically
  • Systematic data extraction eliminates manual copy-paste errors
<cfscript>
    writeOutput("<h2>📧 USE CASE 1: Email Marketing - Customer Mailing Lists</h2>");
    writeOutput("<h3>Business Context:</h3>");
    writeOutput("<p>A marketing department needs to create targeted email campaigns for different customer segments. The CRM system stores customer emails in a database, and ValueList helps convert query results into email lists for bulk messaging systems.</p>");
    
    // Create sample customer data
    customerQuery = queryNew("customerID,email,segment,status", "integer,varchar,varchar,varchar", [
        {"customerID": 1001, "email": "john.smith@techcorp.com", "segment": "Enterprise", "status": "Active"},
        {"customerID": 1002, "email": "mary.jones@startup.io", "segment": "SMB", "status": "Active"},
        {"customerID": 1003, "email": "david.wilson@retailplus.com", "segment": "Enterprise", "status": "Active"},
        {"customerID": 1004, "email": "sarah.brown@localshop.net", "segment": "SMB", "status": "Active"},
        {"customerID": 1005, "email": "mike.davis@corp.example.com", "segment": "Enterprise", "status": "Inactive"}
    ]);
    
    writeOutput("<h4>📊 Customer Database Sample:</h4>");
    writeOutput("<table border='1' cellpadding='8'>");
    writeOutput("<tr><th>Customer ID</th><th>Email</th><th>Segment</th><th>Status</th></tr>");
    
    for (row = 1; row <= customerQuery.recordCount; row++) {
        writeOutput("<tr>");
        writeOutput("<td>" & customerQuery.customerID[row] & "</td>");
        writeOutput("<td>" & customerQuery.email[row] & "</td>");
        writeOutput("<td>" & customerQuery.segment[row] & "</td>");
        writeOutput("<td>" & customerQuery.status[row] & "</td>");
        writeOutput("</tr>");
    }
    writeOutput("</table>");
    
    // Filter active customers for email campaign
    activeCustomerQuery = queryNew("email,segment", "varchar,varchar");
    for (row = 1; row <= customerQuery.recordCount; row++) {
        if (customerQuery.status[row] == "Active") {
            queryAddRow(activeCustomerQuery);
            querySetCell(activeCustomerQuery, "email", customerQuery.email[row]);
            querySetCell(activeCustomerQuery, "segment", customerQuery.segment[row]);
        }
    }
    
    // Generate email lists using ValueList
    allActiveEmails = ValueList(activeCustomerQuery.email);
    enterpriseEmails = ValueList(activeCustomerQuery.email, ";"); // Using semicolon delimiter
    
    writeOutput("<h4>📧 Generated Email Lists:</h4>");
   // writeOutput("<div style='background-color: #f8f9fa; padding: 15px; border: 1px solid #ddd;'>");
    writeOutput("<p><strong>All Active Customers (Comma-delimited):</strong></p>");
    writeOutput("<p><code>" & allActiveEmails & "</code></p>");
    writeOutput("<p><strong>Email Count:</strong> " & listLen(allActiveEmails) & " recipients</p>");
    
    writeOutput("<p><strong>All Active Customers (Semicolon-delimited):</strong></p>");
    writeOutput("<p><code>" & enterpriseEmails & "</code></p>");
    writeOutput("<p><strong>Ready for bulk email system import</strong></p>");
    writeOutput("</div>");
</cfscript>

eCommerce- Product category dropdowns

An e-commerce website serves thousands of products across multiple categories and needs to provide intuitive navigation for customers. Product categories are stored in a database and must be dynamically presented as dropdown menus, breadcrumb navigation, and filter options throughout the website.
How it helps:
  • Category menus automatically reflect new product additions
  • Uniform navigation presentation across all website sections
  • Single query generates all navigation elements
  • Eliminates manual navigation maintenance
<cfscript>
    // Create sample product category data
    categoryQuery = queryNew("categoryID,categoryName,productCount", "integer,varchar,integer", [
        {"categoryID": 101, "categoryName": "Electronics", "productCount": 245},
        {"categoryID": 102, "categoryName": "Clothing", "productCount": 189},
        {"categoryID": 103, "categoryName": "Home & Garden", "productCount": 156},
        {"categoryID": 104, "categoryName": "Sports & Outdoors", "productCount": 98},
        {"categoryID": 105, "categoryName": "Books & Media", "productCount": 67}
    ]);
    
    writeOutput("<h4>📊 Product Categories Database:</h4>");
    writeOutput("<table border='1' cellpadding='8'>");
    writeOutput("<tr><th>Category ID</th><th>Category Name</th><th>Product Count</th></tr>");
    
    for (row = 1; row <= categoryQuery.recordCount; row++) {
        writeOutput("<tr>");
        writeOutput("<td>" & categoryQuery.categoryID[row] & "</td>");
        writeOutput("<td>" & categoryQuery.categoryName[row] & "</td>");
        writeOutput("<td>" & categoryQuery.productCount[row] & "</td>");
        writeOutput("</tr>");
    }
    writeOutput("</table>");
    
    // Generate lists for different purposes
    categoryNames = ValueList(categoryQuery.categoryName);
    categoryIDs = ValueList(categoryQuery.categoryID, "|");
    
    writeOutput("<h4>🎯 Generated Category Lists:</h4>");
    //writeOutput("<div style='background-color: #f8f9fa; padding: 15px; border: 1px solid #ddd;'>");
    writeOutput("<p><strong>Category Names (for display):</strong></p>");
    writeOutput("<p><code>" & categoryNames & "</code></p>");
    
    writeOutput("<p><strong>Category IDs (for form values):</strong></p>");
    writeOutput("<p><code>" & categoryIDs & "</code></p>");
    writeOutput("</div>");
    
    // Simulate HTML dropdown generation
    writeOutput("<h4>🌐 HTML Dropdown Implementation:</h4>");
    //writeOutput("<div style='background-color: #e8f5e8; padding: 15px; border-left: 4px solid #28a745;'>");
    writeOutput("<p><strong>Generated HTML Select:</strong></p>");
    writeOutput("<select name='category' style='padding: 8px; font-size: 14px;'>");
    writeOutput("<option value=''>Select Category...</option>");
    
    categoryNameList = listToArray(categoryNames);
    categoryIDList = listToArray(categoryIDs, "|");
    
    for (i = 1; i <= arrayLen(categoryNameList); i++) {
        if (i <= arrayLen(categoryIDList)) {
            writeOutput("<option value='" & categoryIDList[i] & "'>" & categoryNameList[i] & "</option>");
        }
    }
    writeOutput("</select>");
    writeOutput("<p><strong>Dynamic dropdown with " & listLen(categoryNames) & " categories</strong></p>");
    writeOutput("</div>");
</cfscript>

HR management- Employee skills aggregation

A technology consulting firm manages 200+ employees across multiple projects and needs to track, analyze, and report on employee skills for project staffing, training initiatives, and strategic workforce planning. Skills data is stored individually per employee and requires aggregation for management reporting and resource allocation.
How it helps:
  • Detailed view of organizational capabilities
  • Efficient matching of skills to project needs
  • Data-driven identification of skill development priorities
  • Workforce capability insights for business growth
<cfscript>
    // Create sample employee skills data
    employeeSkillsQuery = queryNew("employeeID,employeeName,skill,proficiency", "integer,varchar,varchar,varchar", [
        {"employeeID": 2001, "employeeName": "Alice Johnson", "skill": "Java", "proficiency": "Expert"},
        {"employeeID": 2001, "employeeName": "Alice Johnson", "skill": "Python", "proficiency": "Advanced"},
        {"employeeID": 2002, "employeeName": "Bob Smith", "skill": "JavaScript", "proficiency": "Expert"},
        {"employeeID": 2002, "employeeName": "Bob Smith", "skill": "React", "proficiency": "Advanced"},
        {"employeeID": 2003, "employeeName": "Carol Davis", "skill": "SQL", "proficiency": "Expert"},
        {"employeeID": 2003, "employeeName": "Carol Davis", "skill": "Python", "proficiency": "Intermediate"},
        {"employeeID": 2004, "employeeName": "David Wilson", "skill": "Java", "proficiency": "Advanced"},
        {"employeeID": 2004, "employeeName": "David Wilson", "skill": "SQL", "proficiency": "Expert"}
    ]);
    
    writeOutput("<h4>📊 Employee Skills Database:</h4>");
    writeOutput("<table border='1' cellpadding='8'>");
    writeOutput("<tr><th>Employee ID</th><th>Employee Name</th><th>Skill</th><th>Proficiency</th></tr>");
    
    for (row = 1; row <= employeeSkillsQuery.recordCount; row++) {
        writeOutput("<tr>");
        writeOutput("<td>" & employeeSkillsQuery.employeeID[row] & "</td>");
        writeOutput("<td>" & employeeSkillsQuery.employeeName[row] & "</td>");
        writeOutput("<td>" & employeeSkillsQuery.skill[row] & "</td>");
        writeOutput("<td>" & employeeSkillsQuery.proficiency[row] & "</td>");
        writeOutput("</tr>");
    }
    writeOutput("</table>");
    
    // Generate skills summary lists
    allSkills = ValueList(employeeSkillsQuery.skill);
    uniqueEmployees = ValueList(employeeSkillsQuery.employeeName, " | ");
    
    // Create expert-level skills query
    expertSkillsQuery = queryNew("skill", "varchar");
    for (row = 1; row <= employeeSkillsQuery.recordCount; row++) {
        if (employeeSkillsQuery.proficiency[row] == "Expert") {
            queryAddRow(expertSkillsQuery);
            querySetCell(expertSkillsQuery, "skill", employeeSkillsQuery.skill[row]);
        }
    }
    
    expertSkills = ValueList(expertSkillsQuery.skill, " • ");
    
    writeOutput("<h4>📋 Skills Summary Reports:</h4>");
    //writeOutput("<div style='background-color: #f8f9fa; padding: 15px; border: 1px solid #ddd;'>");
    writeOutput("<p><strong>All Skills in Organization:</strong></p>");
    writeOutput("<p><code>" & allSkills & "</code></p>");
    writeOutput("<p><strong>Total Skill Entries:</strong> " & listLen(allSkills) & "</p>");
    
    writeOutput("<p><strong>Team Members:</strong></p>");
    writeOutput("<p><code>" & uniqueEmployees & "</code></p>");
    
    writeOutput("<p><strong>Expert-Level Skills (for critical projects):</strong></p>");
    writeOutput("<p><code>" & expertSkills & "</code></p>");
    writeOutput("</div>");
    
    // Skills frequency analysis
    skillsArray = listToArray(allSkills);
    skillFrequency = {};
    
    for (skill in skillsArray) {
        if (!structKeyExists(skillFrequency, skill)) {
            skillFrequency[skill] = 0;
        }
        skillFrequency[skill]++;
    }
    
    writeOutput("<h4>📈 Skills Frequency Analysis:</h4>");
    writeOutput("<table border='1' cellpadding='8'>");
    writeOutput("<tr><th>Skill</th><th>Number of Employees</th><th>Organizational Strength</th></tr>");
    
    for (skill in skillFrequency) {
        count = skillFrequency[skill];
        strength = count >= 3 ? "Strong" : (count >= 2 ? "Moderate" : "Limited");
        strengthColor = count >= 3 ? "green" : (count >= 2 ? "blue" : "red");
        
        writeOutput("<tr>");
        writeOutput("<td><strong>" & skill & "</strong></td>");
        writeOutput("<td>" & count & "</td>");
        writeOutput("<td style='color: " & strengthColor & ";'>" & strength & "</td>");
        writeOutput("</tr>");
    }
    writeOutput("</table>");
</cfscript>

Logistics- Warehouse location tracking

A distribution center processes 2,000+ orders daily across a 100,000 square foot warehouse facility. Inventory is stored in specific bin locations across multiple zones, and order fulfillment requires efficient picking routes to minimize travel time and maximize productivity. Location data needs to be converted into optimized picking sequences.
How it helps:
  • Systematic picking sequences reduce travel time
  • Coordinated workflows between warehouse areas
  • Clear location sequences for new employees
  • Organized picking reduces location mistakes
<cfscript>
    // Create sample inventory location data
    inventoryQuery = queryNew("productCode,productName,warehouseZone,binLocation", "varchar,varchar,varchar,varchar", [
        {"productCode": "ELEC001", "productName": "Wireless Headphones", "warehouseZone": "A", "binLocation": "A-15-03"},
        {"productCode": "ELEC002", "productName": "Bluetooth Speaker", "warehouseZone": "A", "binLocation": "A-12-07"},
        {"productCode": "BOOK001", "productName": "Programming Guide", "warehouseZone": "C", "binLocation": "C-08-12"},
        {"productCode": "CLTH001", "productName": "Cotton T-Shirt", "warehouseZone": "B", "binLocation": "B-22-05"},
        {"productCode": "ELEC003", "productName": "USB Cable", "warehouseZone": "A", "binLocation": "A-18-09"},
        {"productCode": "HOME001", "productName": "Coffee Mug", "warehouseZone": "D", "binLocation": "D-05-15"}
    ]);
    
    writeOutput("<h4>📊 Warehouse Inventory Database:</h4>");
    writeOutput("<table border='1' cellpadding='8'>");
    writeOutput("<tr><th>Product Code</th><th>Product Name</th><th>Zone</th><th>Bin Location</th></tr>");
    
    for (row = 1; row <= inventoryQuery.recordCount; row++) {
        writeOutput("<tr>");
        writeOutput("<td>" & inventoryQuery.productCode[row] & "</td>");
        writeOutput("<td>" & inventoryQuery.productName[row] & "</td>");
        writeOutput("<td>" & inventoryQuery.warehouseZone[row] & "</td>");
        writeOutput("<td>" & inventoryQuery.binLocation[row] & "</td>");
        writeOutput("</tr>");
    }
    writeOutput("</table>");
    
    // Generate location lists for different purposes
    allBinLocations = ValueList(inventoryQuery.binLocation);
    warehouseZones = ValueList(inventoryQuery.warehouseZone, " → ");
    pickingRoute = ValueList(inventoryQuery.binLocation, " → ");
    
    // Filter Zone A locations for electronics picking
    zoneAQuery = queryNew("binLocation", "varchar");
    for (row = 1; row <= inventoryQuery.recordCount; row++) {
        if (inventoryQuery.warehouseZone[row] == "A") {
            queryAddRow(zoneAQuery);
            querySetCell(zoneAQuery, "binLocation", inventoryQuery.binLocation[row]);
        }
    }
    zoneALocations = ValueList(zoneAQuery.binLocation, " ➜ ");
    
    writeOutput("<h4>🎯 Generated Location Lists:</h4>");
    //writeOutput("<div style='background-color: #f8f9fa; padding: 15px; border: 1px solid #ddd;'>");
    writeOutput("<p><strong>All Bin Locations:</strong></p>");
    writeOutput("<p><code>" & allBinLocations & "</code></p>");
    
    writeOutput("<p><strong>Warehouse Zone Route:</strong></p>");
    writeOutput("<p><code>" & warehouseZones & "</code></p>");
    
    writeOutput("<p><strong>Electronics Zone A Picking Route:</strong></p>");
    writeOutput("<p><code>" & zoneALocations & "</code></p>");
    
    writeOutput("<p><strong>Complete Picking Route:</strong></p>");
    writeOutput("<p><code>" & pickingRoute & "</code></p>");
    writeOutput("</div>");
    
    // Generate zone summary
    zoneArray = listToArray(warehouseZones, " → ");
    zoneCounts = {};
    
    for (zone in zoneArray) {
        if (!structKeyExists(zoneCounts, zone)) {
            zoneCounts[zone] = 0;
        }
        zoneCounts[zone]++;
    }
    
    writeOutput("<h4>📈 Warehouse Zone Analysis:</h4>");
    writeOutput("<table border='1' cellpadding='8'>");
    writeOutput("<tr><th>Warehouse Zone</th><th>Number of Items</th><th>Pick Priority</th></tr>");
    
    for (zone in zoneCounts) {
        count = zoneCounts[zone];
        priority = count >= 3 ? "High Volume" : (count >= 2 ? "Medium Volume" : "Low Volume");
        priorityColor = count >= 3 ? "red" : (count >= 2 ? "orange" : "green");
        
        writeOutput("<tr>");
        writeOutput("<td><strong>Zone " & zone & "</strong></td>");
        writeOutput("<td>" & count & " items</td>");
        writeOutput("<td style='color: " & priorityColor & ";'>" & priority & "</td>");
        writeOutput("</tr>");
    }
    writeOutput("</table>");
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page