Coldfusion Array

Ok, I’ve got an array of results for a cfselect based on another cfselect selection.


<cffunction name="getSerialnumbers" access="remote" returntype="any">
    <cfargument name="device" required="yes">
    <cfargument name="partnumber" required="yes">
            <cfquery name="data" datasource="#this.dsn#">
                select isr.serialnumber_id, isr.serialnumber from inventory_serialnumbers isr
                join inventory_partnumber_baselines ipb on ipb.baseline_id = isr.baseline_id
                where ipb.device_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.device#" />
                and ipb.partnumber_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.partnumber#" />
            </cfquery>
            <cfif data.recordCount eq 0>
                <cfset result[1][1]= 0>
                <cfset result[1][2]= "No Serial Numbers Available">
            <cfelse>
                <cfloop index="i" from="1" to="#data.recordCount#">
                    <cfset result[i][1]=data.serialnumber_id[i]>
                    <cfset result[i][2]=data.serialnumber[i]>
                </cfloop>
            </cfif>
<cfreturn result>
</cffunction>

The problem I’m having it that my serialnumbers are being displayed like:

16 instead of 0016

Serialnumber column is : VarChar

yes that worked pre-pending a space to the serialnumber, but it does throw off the balance a i bit… i’ll have to live with it…

untill i find another solution. :slight_smile:

I think it’s a json bug. Try pre-pending a blank space to the isr.serialnumber value in your sql query.

Sounds good. Same net effect, but it just seems a little cleaner to than the “useless space” hack :wink:

You could also try appending it to the end maybe … but still a hack :wink: So if you find anything better, let us know

I decided to go with “serialnumber - location”.

This forces it to display as a string… Works for what I’m doing.