2 Replies - 6497 Views - Last Post: 02 November 2011 - 03:40 PM Rate Topic: -----

#1 dphelan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 28-March 11

Existing function throws Variable X is undefined when calling

Posted 02 November 2011 - 02:24 PM

I have an odd problem that has popped up on me. within a cfc I have separated out some common functionality that all my functions in that cfc use. The function works fine for all but 1 function that returns Variable DRAWQUEUE is undefined when callilng the function. I have tried re-writing the function, prefixing it with variables, moving everything into a new cfc, all without success. I am quite puzzled, especially when 5 of the 6 functions can call the common function successfuly. Has anyone else seen this and know how to correct it? The last time I ran into this, I ended up moving the function to a different cfc, but it made sense to do so. This is a function that will only be called by the code in this cfc, so moving it into another cfc does not make much sense unless I have to, which I shouldn't. The code is below. I am writing in CF 9 on a windows 7 professional machine. The Request approval function is returning the error while the UnavailableLanguage function runs it just fine.

TIA


<cfcomponent displayname="QueueFactory" output="true">
	
	<cffunction name="Init" displayname="Init" access="public" output="false" returntype="com/factories/QueueFactory">
		<cfreturn this>
	</cffunction>
	
	<cffunction name="RequestApproval" displayname="RequestApproval" access="public" output="true" returntype="void">
		<cfargument name="FilterStruct" displayname="FilterStruct" type="com/beans/filter" required="false">
		
		<cfscript>
			var GetRequests = CreateObject("component","com/dao/queuedao").GetRequestQuery(arguments.FilterStruct);
			var FieldOrder = "Candidate,SSN,Email,Service_Branch,Test_Requested,Language,Test_Location,Test_Phone";
			FilterStruct.setStatus(application.Status.New);
			GetRequests = CreateObject("component","com/dao/queuedao").GetRequestQuery(arguments.FilterStruct);
			if(GetRequests.RecordCount gt 0)
				DrawQueue(GetRequests,FieldOrder);
			else
				WriteOutput('<h5 class="StatusEmpty">There are currently no requests that belong to the Request Approval queue</h5>');
		</cfscript>
		
	</cffunction>
	
	<cffunction name="UnavailableLanguage" displayname="UnavailableLanguage" access="public" output="true" returntype="void">
		<cfargument name="FilterStruct" displayname="FilterStruct" type="com/beans/filter" required="false">
		<cfscript>
			var GetRequests = "";
			var FieldOrder = "Candidate,SSN,Email,Service_Branch,Test_Requested,Language,Test_Location,Test_Phone";
			FilterStruct.setStatus(application.Status.Unavail);
			GetRequests = CreateObject("component","com/dao/queuedao").GetRequestQuery(arguments.FilterStruct);
			if(GetRequests.RecordCount gt 0)
				DrawQueue(GetRequests,FieldOrder);
			else
				WriteOutput('<h5 class="StatusEmpty">There are currently no requests that belong to the Unavailable Language queue</h5>');
		</cfscript>
	</cffunction>

......

	<cffunction name="DrawQueue" displayname="DrawQueue" access="private" output="true" returntype="void">
		<cfargument name="QueueQuery" displayname="QueueQuery" type="query" required="true">
		<cfargument name="FieldOrder" displayname="FieldOrder" type="string" required="true">
		<cfset var i = 0>
		<cfset var Field = "">
		
		<div class="InfoRow">
			<div class="ColumnHead" style="width:30px;"><input type="checkbox" onclick="ToggleChecks()" style="width:auto;"></div>
			<cfloop list="#arguments.FieldOrder#" delimiters="," index="Field">
				<div class="ColumnHead">#Replace(Field,"_"," ","All")#</div>
			</cfloop>
		</div>
		<cfoutput query="GetRequests">
			<div class="InfoRow">
				<div class="ColumnHead" style="width:30px;"><input type="checkbox" style="width:auto;"></div>
				<cfloop list="#arguments.FieldOrder#" delimiters="," index="Field">
					<div class="ColumnData">#GetRequests[Field]#</div>
				</cfloop>
			</div>
		</cfoutput>
	</cffunction>
	
</cfcomponent>




Is This A Good Question/Topic? 0
  • +

Replies To: Existing function throws Variable X is undefined when calling

#2 dphelan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 28-March 11

Re: Existing function throws Variable X is undefined when calling

Posted 02 November 2011 - 02:48 PM

I broke the function out into a new cfc which allowed me to run it, and hence displayed all the errors that I had in it(why they didn't show before I broke it out I'm not sure). Once I corrected them and had it working, I tried to put it back into my cfc, but still go the error when trying to call it. Code below has been error corrected.

View Postdphelan, on 02 November 2011 - 02:24 PM, said:

I have an odd problem that has popped up on me. within a cfc I have separated out some common functionality that all my functions in that cfc use. The function works fine for all but 1 function that returns Variable DRAWQUEUE is undefined when callilng the function. I have tried re-writing the function, prefixing it with variables, moving everything into a new cfc, all without success. I am quite puzzled, especially when 5 of the 6 functions can call the common function successfuly. Has anyone else seen this and know how to correct it? The last time I ran into this, I ended up moving the function to a different cfc, but it made sense to do so. This is a function that will only be called by the code in this cfc, so moving it into another cfc does not make much sense unless I have to, which I shouldn't. The code is below. I am writing in CF 9 on a windows 7 professional machine. The Request approval function is returning the error while the UnavailableLanguage function runs it just fine.

TIA


<cfcomponent displayname="QueueFactory" output="true">
	
	<cffunction name="Init" displayname="Init" access="public" output="false" returntype="com/factories/QueueFactory">
		<cfreturn this>
	</cffunction>
	
	<cffunction name="RequestApproval" displayname="RequestApproval" access="public" output="true" returntype="void">
		<cfargument name="FilterStruct" displayname="FilterStruct" type="com/beans/filter" required="false">
		
		<cfscript>
			var GetRequests = CreateObject("component","com/dao/queuedao").GetRequestQuery(arguments.FilterStruct);
			var FieldOrder = "Candidate,SSN,Email,Service_Branch,Test_Requested,Language,Test_Location,Test_Phone";
			FilterStruct.setStatus(application.Status.New);
			GetRequests = CreateObject("component","com/dao/queuedao").GetRequestQuery(arguments.FilterStruct);
			if(GetRequests.RecordCount gt 0)
				DrawQueue(GetRequests,FieldOrder);
			else
				WriteOutput('<h5 class="StatusEmpty">There are currently no requests that belong to the Request Approval queue</h5>');
		</cfscript>
		
	</cffunction>
	
	<cffunction name="UnavailableLanguage" displayname="UnavailableLanguage" access="public" output="true" returntype="void">
		<cfargument name="FilterStruct" displayname="FilterStruct" type="com/beans/filter" required="false">
		<cfscript>
			var GetRequests = "";
			var FieldOrder = "Candidate,SSN,Email,Service_Branch,Test_Requested,Language,Test_Location,Test_Phone";
			FilterStruct.setStatus(application.Status.Unavail);
			GetRequests = CreateObject("component","com/dao/queuedao").GetRequestQuery(arguments.FilterStruct);
			if(GetRequests.RecordCount gt 0)
				DrawQueue(GetRequests,FieldOrder);
			else
				WriteOutput('<h5 class="StatusEmpty">There are currently no requests that belong to the Unavailable Language queue</h5>');
		</cfscript>
	</cffunction>

......

	<cffunction name="DrawQueue" displayname="DrawQueue" access="private" output="true" returntype="void">
		<cfargument name="QueueQuery" displayname="QueueQuery" type="query" required="true">
		<cfargument name="FieldOrder" displayname="FieldOrder" type="string" required="true">
		<cfset var i = 0>
		<cfset var Field = "">
		
		<div class="InfoRow">
			<div class="ColumnHead" style="width:30px;"><input type="checkbox" onclick="ToggleChecks()" style="width:auto;"></div>
			<cfloop list="#arguments.FieldOrder#" delimiters="," index="Field">
				<div class="ColumnHead">#Replace(Field,"_"," ","All")#</div>
			</cfloop>
		</div>
		<cfoutput query="QueueQuery">
			<div class="InfoRow">
				<div class="ColumnHead" style="width:30px;"><input type="checkbox" style="width:auto;"></div>
				<cfloop list="#arguments.FieldOrder#" delimiters="," index="Field">
					<div class="ColumnData">#QueueQuery[Field][QueueQuery.CurrentRow]#</div>
				</cfloop>
			</div>
		</cfoutput>
	</cffunction>
	
</cfcomponent>



Was This Post Helpful? 0
  • +
  • -

#3 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1947
  • View blog
  • Posts: 3,488
  • Joined: 13-January 08

Re: Existing function throws Variable X is undefined when calling

Posted 02 November 2011 - 03:40 PM

dphelan, welcome back!

Looking at your method, the only thing that comes to mind for me for troubleshooting would be to break the cfscript stuff out of it, write it with cf tags and wrap the whole thing in a cftry/cfcatch and then email the cfcatch scope for any catches to yourself so you can see what errored.

I like the cf tags better than script because it should return a line number for any errors and I've seen script errors return the erroring line as the line that contains the CFSCRIPT tag itself and not the script line.

Give that a spin and see what you can get from it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1