Skip to main content
December 5, 2008
Question

CFINCLUDE via OnRequestStart

  • December 5, 2008
  • 2 replies
  • 442 views
I have a CFINCLUDE tag in my application.cfc file's onRequestStart method that includes a template of functions that I commonly use.

Unfortunately, when included via the application.cfc, the functions cannot be called. A simple "functionName()" between CFOUTPUT tags throws a "variable functionName is undefined" error.

If I use a CFINCLUDE tag in the page directly, everything works just fine. I would assume this is some sort of scoping issue, but I'm not sure what scope the function is going to when called via application.cfc. Either that or some other simple, obvious issue that I'm missing. Can anyone point out what I'm forgetting? Thanks!
This topic has been closed for replies.

2 replies

Inspiring
December 6, 2008
Why are you using cfoutput to call your function?
cfjedimaster
Inspiring
December 5, 2008
Things included in onRequestStart are in the scope of the CFC, not your document. You can always put your UDFs in the request scope. So for example, you udf.cfm could do:

request.udfs = structNew();
function foo() { return 1;}
request.udf.foo = foo;

Then to call your function you would use request.udf.foo().