• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Issue with autosuggest on a numeric field

New Here ,
Nov 30, 2007 Nov 30, 2007

Copy link to clipboard

Copied

I have a form with a CFINPUT that has autosuggest to a cfc. The cfc runs a query against a varchar field that has only numeric values. When the match is made and the lis is returned I get an error (Bind failed for autosuggest CUSTOMER, bind value is not a 1D array of strings). This only happens with fields that are all numeric, if the field has any letters or symbols I do not have this issue.

The data returned is coming back as numeric in scientific notation (CFC invocation response: [5.159000038E9]) The data is matching on the phone number and that is what is being returned.

It there a way to correct this issue? Code sample is below.

<cfinput type="text" name="CUSTOMER" size="10" maxlength="10" value="#CUSTOMER#" autosuggest="cfc:customerInfo.getCustomerSuggest({DSN}, {cfautosuggestvalue})">

here is the function from the CFC:

<cffunction name="getCustomerSuggest" access="remote" returntype="array" output="false">
<cfargument name="argDB" type="string" required="yes">
<cfargument name="argCUSTOMER" type="string" required="yes">

<cfset var myarray = ArrayNew(1)>
<cfquery name="cstInfo" datasource="#argDB#" maxrows="25">
SELECT customer
FROM custFile
WHERE customer LIKE <cfqueryparam value="#argCUSTOMER#%" cfsqltype="CF_SQL_VARCHAR">
</cfquery>

<cfloop query="cstInfo">
<cfset arrayAppend(myarray, '#customer# ')>
</cfloop>
<cfreturn myarray>
</cffunction>
TOPICS
Advanced techniques

Views

644

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 01, 2007 Dec 01, 2007

Copy link to clipboard

Copied

I don't understand the actual results desired. But I would make my cffunction returntype a string and get rid of the cfloop that creates your array. One of my autosuggest cfcs is;

<cffunction name="getJobsearch" access="remote" returnType="string" output="false">
<cfargument name="term" type="string" required="false">
<cfset var Jqry = "">
<cfquery name="Jqry" datasource="taxsearchdb">
SELECT J.CompanyName + ' ' + J.CompanyCity + ' ' + C.State + ' ^' + cast(J.JobOrderNumber as varchar) as Jname
FROM jorder J, Companies C
WHERE J.CompanyNumber = C.CompanyRecordNumber and J.CompanyName LIKE <cfqueryparam cfsqltype="cf_sql_var" value="#trim(arguments.term)#%">
</cfquery>
<cfreturn ValueList(Jqry.Jname)>
</cffunction>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 01, 2007 Dec 01, 2007

Copy link to clipboard

Copied

Just a note;
I return a list of fields that has company name and city and state and job number concatenated. The caret ^ is used later to find the job number in the field Jname.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2007 Dec 01, 2007

Copy link to clipboard

Copied

LATEST
Thank you, changing it to a string worked great.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation