5 Replies Latest reply on Mar 22, 2013 12:47 AM by Upen@Roul

    Code Throwing error sometimes.

    Upen@Roul Level 1

      Hi All,


      I am using the following code to convert a ColdFusion Query Object to ColdFusion structure to work in Kendo UI datagrid.



      <cffunction name="convertQueryToKendoJSON" access="public" returntype="Struct" hint="Converts a ColdFusion Query Object into Kendo UI format JSON">

                <cfargument name="queryObject" required="true" type="query" hint="ColdFusion Query Object" />


                <cfset var returnStruct = structNew() />

                <cfset var tempArray = arrayNew(1) />


                <!--- Loop over the query Object and create one structure Object for each row and query fields are the structure keyfields

                          Store the structure into an array Object. --->

                <cfloop query="arguments.queryObject">

                          <cfset tempStruct = structNew() />


                          <cfloop list="#arguments.queryObject.columnList#" index="columnName">

                                    <cfset tempStruct[columnName] = arguments.queryObject[columnName][arguments.queryObject.currentRow] />


                          <cfset arrayAppend(tempArray, tempStruct) />




                <!--- Store the Array into result key field of the returnStruct --->

                <cfset returnStruct['results'] = tempArray />



                <!--- If record Count value exists in the query then only set the totalRecords value --->

                <cfif findNoCase("ntRecordCount", arguments.queryObject.columnList)>

                          <cfset returnStruct['totalRecords'] = arguments.queryObject.ntRecordCount />



                <cfreturn returnStruct />





      It is working fine most of the times. But, in some cases when I am getting the query object from a stored Proc call or from QoQ opearation then I am getting the following error.


      [Table (rows 4 columns NTRECORDCOUNT, NTROWINDEX, NTLEAD_ROUTING_ALGOID, VCROUTING_ALGO, DTCREATED, DTLAST_UPDATED, NTSORT_ORDER): [NTRECORDCOUNT: coldfusion.sql.QueryColumn@10ec6d0] [NTROWINDEX: coldfusion.sql.QueryColumn@11e9be0] [NTLEAD_ROUTING_ALGOID: coldfusion.sql.QueryColumn@8b96e1] [VCROUTING_ALGO: coldfusion.sql.QueryColumn@5e9f7e] [DTCREATED: coldfusion.sql.QueryColumn@3947f5] [DTLAST_UPDATED: coldfusion.sql.QueryColumn@a35419] [NTSORT_ORDER: coldfusion.sql.QueryColumn@e669f3] ] is not indexable by NTSERVICE_TYPEID



      NOTE: I am not getting the error always, sometimes I am getting this error.


      System Info:

      DataBase: MS SQL 2008

      CF - ColdFusion  9,0,2,282541 Enterprise Edition