0
Community Beginner
,
/t5/coldfusion-discussions/call-a-function-within-the-same-cfc-component/td-p/237230
Aug 17, 2007
Aug 17, 2007
Copy link to clipboard
Copied
Hi,
/* Niewbie Question */
I've got a strange problem. When I try to call a function from another in the same CFC component, I get an Error named : « Entity has incorrect type for being called as a function.»
I've looked on many forums and searched in Google Groups. I haven't still found a workaround for that problem.
I thought I've paid attention not o use two times the same name...
Can anyone tell me what error I made ?
My sample code to reproduce this error is included
The complete error message is :
Entity has incorrect type for being called as a function.
The symbol you provided superfunction is not the name of a function.
The error occurred in C:\ColdFusion8\wwwroot\admin\_components\test.cfc: line 6
4 : <cfinvoke
5 : method = "superfunction"
6 : returnVariable = "myReturn">
7 : </cfinvoke>
8 : <cfset some_text = myReturn>
/* Niewbie Question */
I've got a strange problem. When I try to call a function from another in the same CFC component, I get an Error named : « Entity has incorrect type for being called as a function.»
I've looked on many forums and searched in Google Groups. I haven't still found a workaround for that problem.
I thought I've paid attention not o use two times the same name...
Can anyone tell me what error I made ?
My sample code to reproduce this error is included
The complete error message is :
Entity has incorrect type for being called as a function.
The symbol you provided superfunction is not the name of a function.
The error occurred in C:\ColdFusion8\wwwroot\admin\_components\test.cfc: line 6
4 : <cfinvoke
5 : method = "superfunction"
6 : returnVariable = "myReturn">
7 : </cfinvoke>
8 : <cfset some_text = myReturn>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Community Beginner
,
Aug 17, 2007
Aug 17, 2007
OK, solved it with all your tips !!!
Thanks a lot to everybody
Here is the final code for the others...
Thanks a lot to everybody
Here is the final code for the others...
LEGEND
,
/t5/coldfusion-discussions/call-a-function-within-the-same-cfc-component/m-p/237231#M21049
Aug 17, 2007
Aug 17, 2007
Copy link to clipboard
Copied
In your superfunction, scope your argument variables.
In your coolfunction, pass two arguments to the superfunction.
In your coolfunction, pass two arguments to the superfunction.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Philippe Forget
AUTHOR
Community Beginner
,
/t5/coldfusion-discussions/call-a-function-within-the-same-cfc-component/m-p/237233#M21051
Aug 17, 2007
Aug 17, 2007
Copy link to clipboard
Copied
Thanks for replying fast,
I forgot to pass the variables in the exemple, I attached corrected code.
I know what you mean by scoping variables, but how do I do it in CF ? (just three days since my begenning in CF...)
Can you re-paste my code once corrected with the right scoping so I can see how to do this, please? I think it will then make a good exemple post for other niewbies who encounter this problem...
Thanks !
I forgot to pass the variables in the exemple, I attached corrected code.
I know what you mean by scoping variables, but how do I do it in CF ? (just three days since my begenning in CF...)
Can you re-paste my code once corrected with the right scoping so I can see how to do this, please? I think it will then make a good exemple post for other niewbies who encounter this problem...
Thanks !
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guide
,
/t5/coldfusion-discussions/call-a-function-within-the-same-cfc-component/m-p/237238#M21056
Aug 17, 2007
Aug 17, 2007
Copy link to clipboard
Copied
quote:
<!--- Instanciate component --->
<cfinvoke method="objTest.coolfunction">
The error is caused by including the variable name in the "method" value. The correct syntax here is
<cfobject component="test" name="objTest">
<cfinvoke component="#objTest#" method="coolfunction">
As mentioned
1. When referencing variables, include the scope. For example, use "arguments.myArg1" instead of just "myArg1".
2. If a variable is only used inside the function, use the keyword "VAR" to place it in the local scope.
3. Though some are optional, its good to use the attributes like "type", "returnType", "required" and "access"
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/coldfusion-discussions/call-a-function-within-the-same-cfc-component/m-p/237232#M21050
Aug 17, 2007
Aug 17, 2007
Copy link to clipboard
Copied
try the following:
<cfcomponent>
<cffunction name="coolfunction" access="public" returnType="any" output="true">
<cfset some_text= Superfunction(myArg1,myArg2)/>
</cffunction>
<cffunction name="superfunction" access="private" returnType="any" output="true">
<cfargument name="myArg1">
<cfargument name="myArg2">
<cfset myVariable = myArg1&" toto "&myArg2>
<cfreturn myVariable>
</cffunction>
</cfcomponent>
also, I will suggest that you remove the under-score from the folder name "_components"
Good Luck
<cfcomponent>
<cffunction name="coolfunction" access="public" returnType="any" output="true">
<cfset some_text= Superfunction(myArg1,myArg2)/>
</cffunction>
<cffunction name="superfunction" access="private" returnType="any" output="true">
<cfargument name="myArg1">
<cfargument name="myArg2">
<cfset myVariable = myArg1&" toto "&myArg2>
<cfreturn myVariable>
</cffunction>
</cfcomponent>
also, I will suggest that you remove the under-score from the folder name "_components"
Good Luck
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Philippe Forget
AUTHOR
Community Beginner
,
/t5/coldfusion-discussions/call-a-function-within-the-same-cfc-component/m-p/237234#M21052
Aug 17, 2007
Aug 17, 2007
Copy link to clipboard
Copied
Replys to qateef :
Thanks for replying fast too.
I tried your thing but it returns me the following error :
ariable SUPERFUNCTION is undefined.
The error occurred in C:\ColdFusion8\wwwroot\admin\_components\test.cfc: line 6
4 :
5 : <cffunction name="coolfunction" access="public" returnType="any" output="true">
6 : <cfset some_text = superfunction("tata","titi")>
7 : <cfreturn some_text>
8 : </cffunction>
Thanks for replying fast too.
I tried your thing but it returns me the following error :
ariable SUPERFUNCTION is undefined.
The error occurred in C:\ColdFusion8\wwwroot\admin\_components\test.cfc: line 6
4 :
5 : <cffunction name="coolfunction" access="public" returnType="any" output="true">
6 : <cfset some_text = superfunction("tata","titi")>
7 : <cfreturn some_text>
8 : </cffunction>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/coldfusion-discussions/call-a-function-within-the-same-cfc-component/m-p/237235#M21053
Aug 17, 2007
Aug 17, 2007
Copy link to clipboard
Copied
change the access for the superFunction to Public instead of
Private. Make sure the spelling is correct and you need to include
the type for each <cfargument
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/coldfusion-discussions/call-a-function-within-the-same-cfc-component/m-p/237236#M21054
Aug 17, 2007
Aug 17, 2007
Copy link to clipboard
Copied
having Access set to private is totally correct - no need to
change it to public - you're not calling superfunction() directly
so having it set to private is spot on.
Let's have a fresh look at the code you've got so far and we'll get this nailed...
john.
Let's have a fresh look at the code you've got so far and we'll get this nailed...
john.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/call-a-function-within-the-same-cfc-component/m-p/237237#M21055
Aug 17, 2007
Aug 17, 2007
Copy link to clipboard
Copied
> <cfinvoke method="objTest.coolfunction">
Should this not be:
<cfinvoke component="#objTest#" method="coolfunction">
?
--
Adam
Should this not be:
<cfinvoke component="#objTest#" method="coolfunction">
?
--
Adam
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guide
,
/t5/coldfusion-discussions/call-a-function-within-the-same-cfc-component/m-p/237239#M21057
Aug 17, 2007
Aug 17, 2007
Copy link to clipboard
Copied
> Should this not be:
> <cfinvoke component="#objTest#" method="coolfunction">
Nevermind. "Beat me to the punch"
> <cfinvoke component="#objTest#" method="coolfunction">
Nevermind. "Beat me to the punch"
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Beginner
,
LATEST
/t5/coldfusion-discussions/call-a-function-within-the-same-cfc-component/m-p/237240#M21058
Aug 17, 2007
Aug 17, 2007
Copy link to clipboard
Copied
OK, solved it with all your tips !!!
Thanks a lot to everybody
Here is the final code for the others...
Thanks a lot to everybody
Here is the final code for the others...
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

