wiki:FAQEntityIncorectType

Why am I getting " Entity has incorrect type for being called as a function"?

I'm trying to use a framework feature and I'm getting this exception from my CFML engine (where XYZ changes depending on your situation):

Entity has incorrect type for being called as a function.
The symbol you provided XYZ is not the name of a function. 

This is caused by a variable or var'ed variable conflict that matches the name of the method you want call. You can reproduce this exception with the follow code on a scribble page:

<cfset variables.redirectEvent = "" />
<cfset redirectEvent() />

This is because the variables scope is the first scope in the scope search order that CFML engines use. So it finds the variables.redirectEvent variable first and not the redirectEvent() method in the "this" scope (if this was a in the context of a listener, filter or plugin). All methods exist in the variables and this scopes in CFCs so they can cause possible namespace conflicts (just dump the this or variables scope to see that they co-exist in the scopes).

This exception can be fixed by searching through your CFC for a variable name that conflicts with the name of the method you want to call. If you do not want to rename that variable, then you have to use the "this" scope when calling the function:

<cfset this.redirectEvent(...) />

Back to FAQs