|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Calling another function within a function (CFC)
I have a CFC with 2 functions. In the second function I call the first function, but it returns the following error:Spear, Andrew T 11/26/03 04:57 P I've seen this in the past where a user accidently created a variable withRaymond Camden 11/26/03 05:15 P Make sure that nothing else has the same name as both of your functionsTom Kitta 11/26/03 05:27 P Here's the first function:Spear, Andrew T 11/26/03 05:25 P Inside the getWorkflow method you have a variable named getWorkflow, theRaymond Camden 11/26/03 05:41 P Raymond-Spear, Andrew T 11/26/03 05:35 P 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! 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? 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! 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? _____ Inside the getWorkflow method you have a variable named getWorkflow, the query. Rename the query result. 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? _____
|
May 25, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||