House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Calling another function within a function (CFC)

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Spear, Andrew T
11/26/2003 04:57 PM

I have a CFC with 2 functions.  In the second function I call the first function, but it returns the following error: Entity has incorrect type for being called as a function.   The symbol you have provided getWorkflow is not the name of a function. The first function is named "getWorkflow" and returns a struct and it works fine. In the second function I call: WorkflowStruct = getWorkflow(arguments.RequestID); I have no clue why it won't let me call the first function.  Any help would be appreciated!

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
11/26/2003 05:15 PM

I've seen this in the past where a user accidently created a variable with the same name as the method. Can you show us the full code for both methods?

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tom Kitta
11/26/2003 05:27 PM

Make sure that nothing else has the same name as both of your functions (like a veriable name). TK   I have a CFC with 2 functions.  In the second function I call the first function, but it returns the following error:   Entity has incorrect type for being called as a function.   The symbol you have provided getWorkflow is not the name of a function.   The first function is named "getWorkflow" and returns a struct and it works fine.  In the second function I call:   WorkflowStruct = getWorkflow(arguments.RequestID);   I have no clue why it won't let me call the first function.  Any help would be appreciated!

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Spear, Andrew T
11/26/2003 05:25 PM

Here's the first function: <cffunction name="getWorkflow" access="public" returntype="struct" output="No"> <cfargument name="RequestID" type="any" required="yes"> <cfscript> //Set up our instance only vars var PreviousWorkflowID  = ''; var CurrentWorkflowID = ''; var NextWorkflowID  = ''; var WorkflowPath  = ''; var WorkflowPathLen  = ''; var CurrentWorkFlow  = ''; var CurrentIndex  = ''; var ReturnStruct  = StructNew(); </cfscript> <!--- Get workflow info for the requestID ---> <cfquery name="getWorkflow" datasource="#Request.g_DSN#"> ... </cfquery> <cfscript> //Populate some vars for use later on WorkflowPath   = getWorkflow.WorkflowPath; WorkflowPathLen  = ListLen(WorkflowPath); CurrentWorkFlowID = getWorkflow.CurrentWorkflow; CurrentIndex  = ListFind(WorkflowPath,CurrentWorkFlowID); //Get Previous WorkflowID if there is one if (CurrentIndex NEQ 1) {   PreviousWorkflowID = ListGetAt(WorkflowPath,CurrentIndex-1); } //Get Next WorkflowID if there is one if (CurrentIndex NEQ WorkflowPathLen) {   NextWorkflowID = ListGetAt(WorkflowPath,CurrentIndex+1); } //Populate struct for return ReturnStruct.PreviousWorkflowID = PreviousWorkflowID; ReturnStruct.CurrentWorkflowID  = CurrentWorkflowID; ReturnStruct.NextWorkflowID  = NextWorkflowID; </cfscript> <cfreturn ReturnStruct> </cffunction> And here's the first part of the second, it bombs out in the first cfscript block <cffunction name="getNextTasks" access="public" returntype="struct" output="No" hint="This method returns the next workflow for a specific request"> <cfargument name="RequestID" type="any" required="yes"> <cfscript> //Set up our instance only vars var NodeList    = ''; var CurrentGroup  = ''; var CurrentOrder  = ''; var WorkflowEntryIDList = ''; var WorkflowStruct  = ''; var WorkflowID   = ''; var NextWorkflowID  = ''; var ReturnStruct  = StructNew(); //Grab struct from our Workflow object WorkflowStruct   = getWorkflow(arguments.RequestID); WorkflowID    = WorkflowStruct.CurrentWorkflowID; NextWorkflowID   = WorkflowStruct.NextWorkflowID; ReturnStruct.WorkflowID = WorkflowID; ReturnStruct.WorkflowEntryIDList = ''; </cfscript> ..... </cffunction> I've seen this in the past where a user accidently created a variable with the same name as the method. Can you show us the full code for both methods?   _____  

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
11/26/2003 05:41 PM

Inside the getWorkflow method you have a variable named getWorkflow, the query. Rename the query result.

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Spear, Andrew T
11/26/2003 05:35 PM

Raymond- Good call.  I had a query called getWorkflow in the getWorkflow function.  I renamed it and everything works! Thanks so much!! Andrew I've seen this in the past where a user accidently created a variable with the same name as the method. Can you show us the full code for both methods?   _____  


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 25, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference