Skip to main content
April 20, 2009
Question

cffunction not found

  • April 20, 2009
  • 3 replies
  • 728 views

I've recently been translating some custom tags over to <cffunction>, as they execute noticibly faster.  Works great 99% of time.  But once in a while I'll get an error "Variable XYZ is undefined" where XYZ is the name of a function.  I know that it is spelled correctly, and is called previously in the same page.  If I refresh, the error goes away and everything's fine.  If it were a coding error, it seems like the error would be persistent, and not go away.  It may have something to do with sitting idle, as I've noticed this happen after leaving the computer and returning later.  Anyone know how I can prevent this?

    This topic has been closed for replies.

    3 replies

    ilssac
    Inspiring
    April 21, 2009

    Since ColdFusion is loosely typed, this can happen by unintentionally reassigning the function variable.

    <cffunction name="xyz"...>

    ...

    </cffunction>

    <cfset this=xyz()>

    <cfset xyz = "xyz is now a string not a function">

    <cfset that=xyz()>

    The second call to the xyz function will throw the described error.  If the reassignment occures in some conditional logic so that it does not always happen, it can make it more difficult to track down.

    Inspiring
    April 21, 2009

    Are you storing yuor components in session variables? If so then your session is timing out.

    April 21, 2009

    Not stored session.  Just <cffunction name="XYZ"> in a file included in Application.cfm

    Inspiring
    April 20, 2009

    Everytime I've done something like that, it's been because of a structclear(variables).  However, refreshing the page would not solve it.