Interesting ColdFusion 8, Auto-Suggest issue to watch for

This post is more than 2 years old.

Thanks to Ed Tabara for pointing this out. If you type "1" in the search field at ColdFusion Bloggers, you will get a JavaScript error:

The page at says:Bind failed for autosuggest search_query, bind value is not a 1D array of strings [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]

If you introspect the result from my server, you see something like this:


Notice that the first two results were numbers, not strings. I tried to 'fool' JSON a bit. I added "" to the number to see if that would do it and it didn't work. Interestingly enough, if you add " " to your data, serializeJSON will keep the padding on the strings, but removes it from the numbers. So even though my data was "10(space)", serializeJSON ignored it.

So it looks like 2 possible bugs. The client side code should allow for any simple value in the array - numbers, strings, or dates. And it looks like maybe serializeJSON is a bit overzealous in converting values. I can understand converting 10 to 10.0, but "10(space)" should be left alone, especially if "Ray(space)" is left alone.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Kevin Benore posted on 3/18/2008 at 12:26 AM

It is odd. If you try every number (0-9), some error ... some pull results, and others just do nothing. For instance, 1 and 3 error but 2 does nothing. 5 on the other hand finds the result "500 error".

Comment 2 by Don posted on 3/18/2008 at 11:28 PM

Putting an underscore _ wont error, but it also wont show the result found, which is:

["test","camden","getter","robot chicken","william ukoh","william","coldfusion rocks","a","andrea","chad"]

Comment 3 by Doron Katz posted on 4/8/2008 at 3:19 AM

I am just testing your flex solution to the blog engine. Might consider one myself, this looks interesting for sure

Comment 4 by Rakshith posted on 4/11/2008 at 8:37 AM

This is a strange bug. Its now been logged as a bug in our bugtracker.

Thanks for pointing it out.

Comment 5 by PhilNg posted on 5/12/2008 at 6:53 AM

It does the exact same thing for binding values to a drop down to auto-populate. In my case, it converted my "Yes" to "true".

Comment 6 by Joey Vincent posted on 7/31/2008 at 1:09 AM

Hi Ray,

Do you know if this problem was ever resolved? I have just implemented autosuggest and am getting the "bind failed for autosuggest" error when I type a number into the autosuggest box.


Comment 7 by Raymond Camden posted on 7/31/2008 at 1:17 AM

I don't know. Give it a try in 8.0.1 though - that fixed a lot of bugs.

Comment 8 by oMaT posted on 8/1/2008 at 11:30 PM

I'm running 8.0.1 and I'm having the same issue. I'm sifting through a list of invoice IDs, restaurant food items and names and every time the item is a pure integer something insists that it be returned without quotes, making the autosuggest fail some of the time with the 1D array error. No matter how I try to cast the results, I can't get around it. Odd an annoying.

Comment 9 by Joey Vincent posted on 8/2/2008 at 2:44 AM

Yeah, I don't think it's fixed. We're also running 8.0.1 and I still get the same error.

Comment 10 by Chris Amaro posted on 9/4/2008 at 10:25 PM

Having the same issue here as well. Simple form for retrieving ticket #'s (formatted 'mmddyyxxx' with 'xxxx' being an incremental). Any digit entered into the input field throws the "1D Array" error. Running 8.0.1.

Comment 11 by Raymond Camden posted on 9/4/2008 at 11:03 PM

I'm really surprised this isn't fixed in 8.0.1. Or the CHF for it. I guess I'd recommend then not using this feature at all. You could probably find a simple jQuery solution, and Spry supports autosuggest as well.

Comment 12 by Greg Koehlinger posted on 9/5/2008 at 7:58 PM

I was having binding problems with autosuggest as well when pulling back long numbers with leading zeros (e.g. 0001234567) and got scientific notation added by JSON serialization. I figured out a workaround that solves the binding and serialization problem for the time being.

In your CFC method, return an extra alphabetical list element that will never match any data in the first character of data--I decided to use "$" but you could use any character. For example: <cfreturn "$," & ValueList(someQuery.SOME_COLUMN)> The "$" never matches any of my data but it causes the bind to work and problems with JSON serialization of the long number are also solved.

Comment 13 by Alirio Boquin posted on 9/27/2008 at 4:11 AM

Hi there,

I spend a lot time try to fix this issue, but now I known I not the only, like Raymond said, just wait for a fix.

To continue with my project I use this Ben solution.
"Using the client-side auto-suggest control"

It's the first one, and works very nice.

Good look fellows.

See you around.


Comment 14 by Dave Burgan posted on 10/22/2008 at 9:01 PM

Has anyone come up with a solution for 'Bind failed for autosuggest, bind value is not a 1D array of strings'. Changing the returned results from my CFC to a string has not made a difference. It seems to only happen in Firefox.

Comment 15 by Greg Koehlinger posted on 10/22/2008 at 11:08 PM

See my suggestion above: <cfreturn "$," & ValueList(someQuery.SOME_COLUMN)> That worked for me.

Also, make sure that if you are using CFCs, do not have any end of request processing (OnRequestEnd.cfm or method in application.cfc) that might add additional characters or blank spaces to the returned data. Once I fixed that, my autosuggest fields started working.

Comment 16 by Dave Burgan posted on 10/22/2008 at 11:30 PM

Thanks for the suggestion Greg, but that doesn't change the behavior for me. Still the same result. Any other ideas? Like I said, it only seems to happen in Firefox, and it's also related to the speed you type. If I type slow enough for the autocomplete to keep up, everything is cool. But if I type really fast and hit enter the error pops up.

Comment 17 by Greg Koehlinger posted on 10/23/2008 at 12:36 AM

I used the autosuggestBindDelay="1" parameter (1 second) in my <cfinput> tag and had fewer problems with speed of typing than if I left the parameter out (default is 0.5 seconds). Set higher if needed but anything higher than 3 would not seem useful for an autosuggest feature. The speed of your network and .cfc calls could affect performance. If the round-trip Ajax call takes 2 seconds and your autosuggestBindDelay is at the default of 0.5 seconds, I can imagine some collisions occurring as multiple Ajax requests return in 2, 4, 6, etc. seconds.

I have the luxury of targeting only MSIE.

Comment 18 by Eric Hayes posted on 12/23/2008 at 1:48 AM

I know this was posted months ago, but I thought I'd add a quick note about integers and SerializeJSON:

For integer values and SerializeJSON note that this will return an integer in JSON form:

<cfset someInt = 1 />
<cfset JavaCast("int", someInt) />
<cfset SerializeJSON(someInt) />

Otherwise values you think are integers may be treated as strings or floating points.

Comment 19 by Abhi posted on 4/9/2009 at 6:40 PM

Bind Failed Error -

The cause of the error for me was the JSON text being returned in not absolutely JSON (it included header in the onRequestStart). Removing that worked! Not a Bug

Comment 20 by Adam posted on 7/24/2009 at 6:37 PM

While Adobe works on a fix, I came up with a work-around.
Disable the Enter key as a means to submit the form. In other words, force the user to click an actual Submit button.

Install the js here:

Comment 21 by Greg posted on 10/7/2009 at 10:49 PM

After coming across this thread (and groaning appropriately), I found that if I merely prepend a comma to the string result, it prevents the conversion of a single numerical string result from being interpreted as a number. In other words (and in pseudocode),
if (recordCount EQ 1)
return ',' + ValueList(...);
return ValueList(...);

Comment 22 by Bill Davidson posted on 12/10/2009 at 11:08 PM

So even worse, serializeJSON converts numeric strings to scientific notation!
test = {x="121414124"};
return serializeJSON(test);

you'll get {"X":1.21414124E8}

I even tried javaCast'ing it is a string, yet this still converts it to scientific notation. This is a horrible bug in CF 8.x. Anyone have a workaround BESIDES adding crap to the string and then doing a replace()? That's so ugly.

Comment 23 by Raymond Camden posted on 12/10/2009 at 11:22 PM

Unfortunately no, not in CF9 either.

Comment 24 by Dave Markle posted on 3/3/2010 at 8:39 PM

This is ridiculous. I'm using EXTJS with CF being the backside (intended). And I'm returning pretty large structures of data via ajax to my ext code. And all my INT's are converted to scientific notation. Useless. Coldfusion screws me again. Another example of shoddy bug tracking and implementation by the Coldfusion team. I am committed to Coldfusion, but only because I'm forced. After dealing with the countless bugs in cfdocument, cfchart, the entire cf8 ajax libraries... now a simple function like serializejson can't return an int??? Stupid stupid stupid.

I'm returning too much data to selectively add "$" or "," to the beginning of my integers. Additionally, I refuse that solution on grounds of principle.

Does anyone know anything more about this?

Sorry for the rant. I don't only hate coldfusion... occasionally I love hating it.

Comment 25 by Raymond Camden posted on 3/3/2010 at 8:44 PM

Dave, how about trying JSON.cfc?

I believe it may handle the numeric issue a bit better.

Also, you can consider using SQL to prepend your column with $ (you will need to cast as well). It would be done totally in SQL then and should perform well. You can also use JavaCast to cast the data to int - Todd Sharp has blogged on that.

Comment 26 by todd sharp posted on 3/3/2010 at 8:46 PM

I never blogged on it - just tweeted. But, yeah, just do a javacast(int, yourval) and then serializeJSON and you'll avoid the annoying 'decimal' conversion.

Comment 27 by Dave posted on 3/3/2010 at 9:04 PM

I'm of the opinion that CF keeps adding features that sound really cool on paper but when you go to use them they don't work quite right and never get fixed. Adobe just moves on to creating the next cool sounding widget to get you to buy the next version, only to find it doesn't work the way it's supposed to either. Autocomplete, cfmail's slow performance, and Flash based forms jump to mind as examples that have caused me headaches because they sort of work, but not quite.

Comment 28 by Raymond Camden posted on 3/3/2010 at 9:10 PM

Well, we are a bit off topic now, but let me respond to this a bit.

1) Slow Mail
Are you sure? Last time I checked cfmail was EXTREMELY fast. I don't have the #s in front of me and I may be wrong, but I thought CF8 Ent was clocked at 500K emails per hour. Remember, once cf hands off the message, it is up to the mail server to deliver it.

2) Flash Forms/other features
Well, I definitely don't use Flash Forms anymore. They were added before the Flex SDF was free so now I definitely push folks to Flex. That being said, it is important to remember that now every feature is for you! Ajax is a great example of this. CF provides support for Ajax both in pluming (JSON serialization, returnFormat in CFCs) and in UI. The UI stuff isn't perfect. You can do more with Ext/jQuery UI. But for people who know little to no Ajax, it is a killer feature.

Comment 29 by Dave Markle posted on 3/3/2010 at 9:16 PM

Thanks fellas.

<cfset myVar = javacast('int' origIntVal)>
<cfreturn serializeJson(myVar)>

Did the trick. I had read up above in this thread that javacast did NOT work... but that guy was javacast'ing to a string and not an int.

I take back what I said about Coldfusion. Actually, I don't take it back. Coldfusion is the pits, but its user base is excellent. I'm always on your blogs and getting great help. Thanks for all the help.

I'll give cfjson a shot too. That will probably be a better long term solution. My data structures are pretty big and I don't feel much like having to javacast everything. Though I will if I have to. I'm just glad that I have a solution.

Thanks again!

Comment 30 by Brook posted on 3/4/2010 at 6:39 AM

I'm having the same problem with yes/no string being converted to boolean values when serialized.

Adobe needs to fix this. The JSON.cfc library is considerably slower for very large (an array of 400 + objects (with more nested structs) each with 50 keys).

But it would be even slower to iterate through this big ass piece of data and scrub it to get my data back in the correct format.

If it was a small amount of data it would be okay to add a space after "yes " and then remove it on the way back (post deserialize()), but as it stands, I am running out of options. Does any one have any suggestions?

Comment 31 by Raymond Camden posted on 3/4/2010 at 6:58 AM

To be fair, 400+ objects with 50 keys is a lot to serialize.

That being said - if you don't need _dynamic_ serialization (ie, you know exactly what you want - you can write your own code. JSON is pretty trivial to generate. Just be sure to use stringBuffer's via createObject.

Comment 32 by Gregory Alexander posted on 3/25/2011 at 1:56 AM

To fix this, comment out line 28 in cfautosuggest.js

And comment out line 75 in cfmessage.js //m['autosuggest.loadautosuggest.invalidvalue']='Bind failed for autosuggest {0}, bind value is not a 1D array of strings'

Make sure to add a comment that you changed the code for documentation, and re-check if you upgrade from cf8 to 9.

Comment 33 by Thomas Cross posted on 11/4/2011 at 12:25 AM

string did not work and i wanted more bits than log so I did bigdecimal.
bigdecimal (converts to java.math.BigDecimal) = javacast('bigdecimal',;

Comment 34 by Robert posted on 12/9/2011 at 11:47 PM

Very, very frustrating that this is still a bug nearly four years later.
None of the suggestions in this thread have worked for me.
It's quite frustrating when you go to do something in CF and it just does not work. And they know it.
I need a MaiTai, who's with me?

Comment 35 by Raymond Camden posted on 12/10/2011 at 12:02 AM

JSON seriliazation has been much improved in CF9. As for the autusuggest tool, if it still doesnt work well for you, consider the jQuery UI one. You can use that easily enough with CF.

Comment 36 by Matt posted on 1/24/2012 at 8:32 AM

JavaCast("Long", Variable) fixs the issue before serializing the data structure.