ColdFusion Bug: ValueList() Will Not Except Dynamic Column Names...

Posted by Dan on Jul 11, 2005 @ 5:24 PM

I came across what is apparently an old Macromedia ColdFusion "bug" today in the valueList() function. The valueList() function will only accept a value where both the queryName and columnName are static values in the form: queryName.columnName.

It appears it'll throw an error if you try passing any other combination of equally valid syntax. For example, all of the below will throw an error, even though they are all valid references to a query and column.


Even though all of the above are valid ways to references to a column in a query, they generate an error in ColdFusion MX v6.1 and 7.0. I've been told this will generate errors in even older versions of CF.

Fortunately, Raymond Camden has posted a UDF over at that you can use as a workaround. The function is called DynamicValueList().

Interestly enough, BlueDragon does not apparently suffer from this bug—and it definitely is a bug in my book and not just a behavior issue. You should be able to pass in any valid reference to a column object to get a valueList() returned.
Categories: HTML/ColdFusion


  • Not to be a stick in the mud, but it's Camden, not Camdem. ;)
  • Sorry 'bout that. I'm blaming it on sticky fingers! (After I all, I typed it right in your URL!)

    I've corrected the typo...
  • Uh, not to be another stick in more mud, but when valueList() won't EXCEPT the arg, does it throw an ACCEPTION? :-)

    Kidding aside, good tip. I see Ray's UDF dates from 2002 but I wouldn't have thought to look for it if I ran into the bug.
  • Lars,

    Yes, it throws an error and execution stops.

  • This has come up before, and basically what it boils down to is that valueList isn't a real function, but a compiler directive. Since it happens at compile time, you can't do anything that depends on runtime data. And that goes for your first example, because the string is a separate object literal, not an identifier.

    So not a bug, an intentional design characteristic, but I agree it should be "fixed".
  • Barney,

    I think you've got to be correct in your assumptions about it being a compiler directive, but how come it would work if you did a "select * from table" if it was actually a compile time directive? How would it know a column name is valid until runtime?

    By the, just out of curiosity, I tested:

    oCol = queryName.columnName;

    And it too throws an error.

Comments for this entry have been disabled.