Skip to main content
August 11, 2010
Question

Problems with application scope variable in remote functions

  • August 11, 2010
  • 2 replies
  • 683 views

I have a cfc folder with all my cfcs. All my public and private functions are able to get the APPLICATION variables just fine, but for whatever reason I get errors like...

Error invoking CFC /web/admin/cfc/documents.cfc : Element DS is undefined in APPLICATION.

Basically I am trying to retrieve APPLICATION.DS which is the variable that stores my datasource.

Any ideas as to why only remote functions suffer from this problem?

    This topic has been closed for replies.

    2 replies

    Inspiring
    August 11, 2010

    When you call your public methods, you'll be calling them from a request to a CFM template that is in a specific application context (eg: there's a <cfapplication> tag somewhere in the mix, or an Application.cfc).

    If your CFCs are in a subdir structure which doesn't run in that application context then you will not have access to that application context's variables.

    Which is what I suspect is your problem.

    You should not be accessing application-scoped variables in a CFC method though, really (as Dan alludes to).

    --

    Adam

    August 13, 2010

    Found the problem. It turns out the problem was that I was calling an old CFC from the CFM on accident. I had to change folder structure for certain reasons and the links were never fixed.

    Thanks all.

    Inspiring
    August 11, 2010

    It's because they are not part of the application.  To solve this problem, make the datasource an argument of your function and pass a value when you call that function.