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

The value returned from the load function is not of type numeric errors after migration to Coldfusion 11

New Here ,
Feb 18, 2015 Feb 18, 2015

Copy link to clipboard

Copied

I am currently testing our website with CF11. It is currently working with CF8 however after migrating it to a new server running CF11 I have encountered the following error.

The value returned from the load function is not of type numeric.

The error occurred in

D:/Applications/CFusion/CustomTags/nec/com/objects/address.cfc: line 263
Called from D:/Applications/CFusion/CustomTags/nec/com/objects/contact.cfc: line 331

Called from D:/Applications/CFusion/CustomTags/nec/com/objects/user.cfc: line 510

Called from D:/Applications/CFusion/CustomTags/nec/com/objects/user.cfc: line 1675

Called from D:/website/NECPhase2/action.validate.cfm: line 54

261 : <cfif isNumeric(get.idCountry)>

262 : <cfset rc = this.objCountry.setID(get.idCountry)>

263 : <cfset rc = this.objCountry.load()>

264 : </cfif>

265 : <cfset this.sPostcode = get.sPostcode>

Have there been any changes between CF8 and CF11 that could  cause this error?

Does anyone have ideas?

Views

345

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

correct answers 1 Correct answer

Engaged , Feb 18, 2015 Feb 18, 2015

The problem is in the load function.  There is a return true at the end of the function.  The returntype of the function is set to numeric.  True is not numeric so it will throw an error.

Votes

Translate

Translate
Engaged ,
Feb 18, 2015 Feb 18, 2015

Copy link to clipboard

Copied

There have been tons of changes from 8 to 11.  Can you share the code that the error is referencing? 

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 ,
Feb 18, 2015 Feb 18, 2015

Copy link to clipboard

Copied

Thank you for your quick reply.

Here is the section of code from address.cfc that the error points at:

<cfquery name="get" datasource="#sDatasource#">
    SELECT idAddressID, RTRIM(sAddressLine1) as sAddressLine1, RTRIM(sAddressLine2) as sAddressLine2, RTRIM(sAddressLine3) as sAddressLine3, RTRIM(sTown) as sTown, RTRIM(sCounty) as sCounty, RTRIM(sPostcode) as sPostcode, idCountry
    FROM tblAddress
    WHERE idAddressID = #this.idAddressID#
   </cfquery>
   <cfcatch>
    <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("load: get: #cfcatch.detail#");
    </cfscript>
    <cfset this.iErrorID = iErrorID>
    <cfreturn iErrorID>
   </cfcatch>
  </cftry>

  <cfset this.idAddressID = get.idAddressID>
  <cfset this.sAddressLine1 = get.sAddressLine1>
  <cfset this.sAddressLine2 = get.sAddressLine2>
  <cfset this.sAddressLine3 = get.sAddressLine3>
  <cfset this.sTown = get.sTown>
        <cfset this.sCounty = get.sCounty>
  <cfif isNumeric(get.idCountry)>
   <cfset rc = this.objCountry.setID(get.idCountry)>
   <cfset rc = this.objCountry.load()>
  </cfif>
  <cfset this.sPostcode = get.sPostcode>
  <cfset this.iErrorID = "">

  <cfreturn true>

The idCountry in the cfquery is an integer value. Which should return a string value such as "United Kingdom" from this.objCountry mentioned in the script below.

This script may also assist:

<cfscript>

  this.idAddressID = 0;

  this.sAddressLine1 = "";

  this.sAddressLine2 = "";

  this.sAddressLine3 = "";

  this.sTown = "";

  this.sCounty = "";

  this.sPostcode = "";

  this.objCountry = CreateObject( 'component', 'nec.com.objects.country' );

  this.iErrorID = "";

</cfscript>

I have noticed similar errors that fail on lines containing  <cfset rc = this.XXXXXX.load()>. Has something changed with the way CF11 handles this code?

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
Engaged ,
Feb 18, 2015 Feb 18, 2015

Copy link to clipboard

Copied

Can you share the code from here:    this.objCountry = CreateObject( 'component', 'nec.com.objects.country' );

That is where the issue is going to be.. not with the calling code.  Please try not to put in just an excerpt as you may cut off something important.

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 ,
Feb 18, 2015 Feb 18, 2015

Copy link to clipboard

Copied

This is the code in file object file country.cfc (nec.com.objects.country):

<cfcomponent displayname="Country object" hint="This is a Country object, it allows you to access and set values in the Country.">

<!---
// ########################################################################################
//
// Construct this object
//
// ########################################################################################
--->

<cfset this.objFunctions = CreateObject( 'component', 'nec.com.system.functions' )>

<cfscript>
  this.idCountryID = 0;
  this.sCountryName = "";
  this.sISOCode = "";
  this.sDHLCode = "";
  this.iErrorID = "";
</cfscript>






<!---
// ########################################################################################
//
// The following functions are the setters and getters. offering us a better way to get
// at the contents of the object
//
// ########################################################################################
--->


<!---
//
// Getters
//
--->

<cffunction name="getID" displayname="Get ID" returntype="numeric" output="false" hint="This returns the ID of the current item.">
  <cfreturn this.idCountryID>
</cffunction>

<cffunction name="getsCountryName" displayname="Get sCountryName" returntype="string" output="false" hint="This gets the sCountryName value of this item.">
  <cfreturn this.sCountryName>
</cffunction>

<cffunction name="getsISOCode" displayname="Get sISOCode" returntype="string" output="false" hint="This gets the sISOCode value of this item.">
  <cfreturn this.sISOCode>
</cffunction>

<cffunction name="getsDHLCode" displayname="Get sDHLCode" returntype="string" output="false" hint="This gets the sDHLCode value of this item.">
  <cfreturn this.sDHLCode>
</cffunction>

<cffunction name="iError" displayname="Get iError" returntype="numeric" output="false" hint="This returns the iError of the current item.">
  <cfreturn this.iError>
</cffunction>

<!---
//
// Setters
//
--->

<cffunction name="setID" displayname="Set ID" returntype="boolean" output="false" hint="This sets the ID value of this item.">
  <cfargument name="idCountryID" required="true" type="numeric" displayname="ID" hint="The ID to use.">
  <cfset this.idCountryID = arguments.idCountryID>
  <cfreturn true>
</cffunction>

<cffunction name="setsCountryName" displayname="Set sCountryName" returntype="boolean" output="false" hint="This sets the sCountryName value of this item.">
  <cfargument name="sCountryName" required="true" type="string" displayname="sCountryName" hint="The sCountryName to use.">
  <cfset this.sCountryName = arguments.sCountryName>
  <cfreturn true>
</cffunction>

<cffunction name="setsISOCode" displayname="Set sISOCode" returntype="boolean" output="false" hint="This sets the sISOCode value of this item.">
  <cfargument name="sISOCode" required="true" type="string" displayname="sISOCode" hint="The sISOCode to use.">
  <cfset this.sISOCode = arguments.sISOCode>
  <cfreturn true>
</cffunction>

<cffunction name="setsDHLCode" displayname="Set sDHLCode" returntype="boolean" output="false" hint="This sets the sDHLCode value of this item.">
  <cfargument name="sDHLCode" required="true" type="string" displayname="sDHLCode" hint="The sDHLCode to use.">
  <cfset this.sDHLCode = arguments.sDHLCode>
  <cfreturn true>
</cffunction>


<!---
//
// Clear, to empty out the contents of this object
//
--->

<cffunction name="clear" displayname="Clear items Details" returntype="boolean" output="false" hint="Clears out all of the items details.">
  <cfscript>
   this.sCountryName = "";
   this.sISOCode = "";
   this.sDHLCode = "";
   this.iErrorID = "";
  </cfscript>
  <cfreturn true>
</cffunction>






<!---
// ########################################################################################
//
// The following functions deal with the load, save and deleting of objects
//
// ########################################################################################
--->


<!---
//
// Load
//
--->
<cffunction name="load" displayname="Load items details" returntype="numeric" output="false" hint="This loads in all the information about an item.">
   
  <cfset rc = this.clear()>
   
  <!---
  // First of all we need to get the name of the data source we are going to be using
  --->
  <cfscript>
  objDS = CreateObject("component","nec.com.system.settings");
  sDatasource = objDS.getDatasource();
</cfscript>

  <!---
  // Check to see if it exists
  --->
  <cftry>
   <cfquery name="checkID" datasource="#sDatasource#">
    SELECT idCountryID
    FROM tblCountry
    WHERE idCountryID = #this.idCountryID#
   </cfquery>
   <cfcatch>
    <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("load: checkID: '#this.idCountryID#' #cfcatch.detail#");
    </cfscript>
    <cfset this.iErrorID = iErrorID>
    <cfreturn iErrorID>
   </cfcatch>
  </cftry>

  <cfif not checkID.recordCount>
   <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     if(isDefined("session.afr")){
      whichOne = "#session.afr.getsAFRNumber()#";
     } else {
      whichOne = "";
     }
     iErrorID = objError.addError("A Country with that id doesn't exists.[#this.idCountryID#][#whichOne#]");
    </cfscript>
   <cfset this.iErrorID = iErrorID>
   <cfreturn iErrorID>
  </cfif>
 
  <!---
  // If we got past all then then load in the details
  --->
  <cftry>
   <cfquery name="get" datasource="#sDatasource#">
    SELECT idCountryID, RTRIM(sCountryName) as sCountryName, RTRIM(sISOCode) as sISOCode, RTRIM(sDHLCode) as sDHLCode
    FROM tblCountry
    WHERE idCountryID = #this.idCountryID#
   </cfquery>
   <cfcatch>
    <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("load: get: #cfcatch.detail#");
    </cfscript>
    <cfset this.iErrorID = iErrorID>
    <cfreturn iErrorID>
   </cfcatch>
  </cftry>

  <cfset this.idCountryID = get.idCountryID>
  <cfset this.sCountryName = get.sCountryName>
  <cfset this.sISOCode = get.sISOCode>
  <cfset this.sDHLCode = get.sDHLCode>
  <cfset this.iErrorID = "">

  <cfreturn true>

</cffunction>


<!---
//
// Save
//
--->
<cffunction name="save" displayname="Save items Details" returntype="numeric" output="false" hint="Saves (to some source) the current details for the ID of the item.">
 
  <!---
  // First of all we need to get the name of the data source we are going to be using
  --->
  <cfscript>
  objDS = CreateObject("component","nec.com.system.settings");
  sDatasource = objDS.getDatasource();
</cfscript>
 
  <!---
  // Now check to see if ithat ID exists
  --->
  <cftry>
   <cfquery name="checkID" datasource="#sDatasource#">
    SELECT idCountryID
    FROM tblCountry
    WHERE idCountryID = #this.idCountryID#
   </cfquery>
   <cfcatch>
    <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("save: checkID: #cfcatch.detail#");
    </cfscript>
    <cfreturn iErrorID>
   </cfcatch>
  </cftry>
 
  <!---
  // If it doesn't exist, then add the record, otherwise update the record
  --->
  <cfif not checkID.recordCount>
   <cfreturn this.add()>
  <cfelse>
   <cfreturn this.update()>
  </cfif>
 
</cffunction>


<!---
//
// Add
//
--->
<cffunction name="add" displayname="Add Country" returntype="numeric" output="false" hint="This adds a Country.">

  <!---
  // Check to see if that a different item isn't already using the same unique details
  --->
  <cftry>
   <cfquery name="checkUnique" datasource="#sDatasource#">
    SELECT idCountryID
    FROM tblCountry
    WHERE sCountryName = '#this.objFunctions.scrubText(this.sCountryName)#'
    OR sISOCOde = '#this.objFunctions.scrubText(this.sISOcode)#'
   </cfquery>
   <cfcatch>
    <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("add: checkUnique: #cfcatch.detail#");
    </cfscript>
    <cfreturn iErrorID>
   </cfcatch>
  </cftry>
 
  <cfif checkUnique.recordCount>
   <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("A Country with that name or ISO code already exists. idCountryID=#checkUnique.idCountryID#");
    </cfscript>
   <cfreturn iErrorID>
  </cfif>

  <cftry>
   <cfquery name="add" datasource="#sDatasource#">
    SET nocount on
    INSERT INTO tblCountry(sCountryName, sISOCode, sDHLCode)
    VALUES('#this.objFunctions.scrubText(this.sCountryName)#','#this.objFunctions.scrubText(this.sISOCode)#','#this.objFunctions.scrubText(this.sDHLCode)#')
    SELECT @@identity as autoID
    SET nocount off  
   </cfquery>
   <cfcatch>
    <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("add: add: #cfcatch.detail#");
    </cfscript>
    <cfreturn iErrorID>
   </cfcatch>
  </cftry>

  <cfreturn add.autoID>

</cffunction>

<!---
//
// Update
//
--->
<cffunction name="update" displayname="Update Country" returntype="numeric" output="false" hint="This updates a Country record.">

  <!---
  // Check to see if that a different item isn't already using the same unique details
  --->
  <cftry>
   <cfquery name="checkUnique" datasource="#sDatasource#">
    SELECT idCountryID
    FROM tblCountry
    WHERE (sCountryName = '#this.objFunctions.scrubText(this.sCountryName)#'
    OR sISOCOde = '#this.objFunctions.scrubText(this.sISOcode)#')
    AND idCountryID <> #this.idCountryID#
   </cfquery>
   <cfcatch>
    <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("update: checkUnique: #cfcatch.detail#");
    </cfscript>
    <cfreturn iErrorID>
   </cfcatch>
  </cftry>
 
  <cfif checkUnique.recordCount>
   <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("Another Country with that name already exists. idCountryID=#checkUnique.idCountryID#");
    </cfscript>
   <cfreturn iErrorID>
  </cfif>


  <!---
  // Attempt to update the record to the datasource
  // if this fails for any reason then we submit an error message
  // to the error component and return the ID of the error
  --->
  <cftry>
   <cfquery name="update" datasource="#sDatasource#">
    UPDATE tblCountry
    SET sCountryName = '#this.objFunctions.scrubText(this.sCountryName)#',
    sISOCode = '#this.objFunctions.scrubText(this.sISOCode)#',
    sDHLCode = '#this.objFunctions.scrubText(this.sDHLCode)#'
    WHERE idCountryID = #this.idCountryID#
   </cfquery>
   <cfcatch>
    <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("update: update: #cfcatch.detail#");
    </cfscript>
    <cfreturn iErrorID>
   </cfcatch>
  </cftry>

  <cfreturn this.idCountryID> 
  
</cffunction>


<!---
//
// Delete
//
--->
<cffunction name="delete" displayname="Delete Country" returntype="numeric" output="false" hint="This deletes a Country record.">

  <!---
  // First of all we need to get the name of the data source we are going to be using
  --->
  <cfscript>
  objDS = CreateObject("component","nec.com.system.settings");
  sDatasource = objDS.getDatasource();
</cfscript>
 
  <!---
  // Now check to see if ithat ID exists
  --->
  <cftry>
   <cfquery name="checkID" datasource="#sDatasource#">
    SELECT idCountryID
    FROM tblCountry
    WHERE idCountryID = #this.idCountryID#
   </cfquery>
   <cfcatch>
    <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("delete: checkID: #cfcatch.detail#");
    </cfscript>
    <cfreturn iErrorID>
   </cfcatch>
  </cftry>
 
  <cfif not checkID.recordCount>
   <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("A Country with that id doesn't exists, delete failed.");
    </cfscript>
   <cfreturn iErrorID>
  </cfif>


  <!---
  // Now check to see if there are any dependancies, if so we can't delete the item
  --->
  <cftry>
   <cfquery name="checkDependancies" datasource="#sDatasource#">
    SELECT idCountry
    FROM tblAddress
    WHERE idCountry = #this.idCountryID#
   </cfquery>
   <cfcatch>
    <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("delete: checkDependancies: idCountry: #cfcatch.detail#");
    </cfscript>
    <cfreturn iErrorID>
   </cfcatch>
  </cftry>
 
  <cfif checkDependancies.recordCount>
   <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("That Country is being used by an address, delete failed.");
    </cfscript>
   <cfreturn iErrorID>
  </cfif>
 
  <!---
  // Now attempt to remove the record.
  // if this fails for any reason then we submit an error message
  // to the error component and return the ID of the error
  --->
  <cftry>
   <cfquery name="delete" datasource="#sDatasource#">
    DELETE FROM tblCountry
    WHERE idCountryID = #this.idCountryID#
   </cfquery>
   <cfcatch>
    <cfscript>
     objError = CreateObject("component","nec.com.system.errors");
     iErrorID = objError.addError("delete: delete: #cfcatch.detail#");
    </cfscript>
    <cfreturn iErrorID>
   </cfcatch>
  </cftry>
   
  <cfreturn this.idCountryID>
  
</cffunction>

</cfcomponent>

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
Engaged ,
Feb 18, 2015 Feb 18, 2015

Copy link to clipboard

Copied

The problem is in the load function.  There is a return true at the end of the function.  The returntype of the function is set to numeric.  True is not numeric so it will throw an error.

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 ,
Feb 18, 2015 Feb 18, 2015

Copy link to clipboard

Copied

That did the trick

Thank you for pointing me in the right direction.

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
Community Expert ,
Feb 18, 2015 Feb 18, 2015

Copy link to clipboard

Copied

LATEST

Great. Please mark the correct answer.

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