Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I call a second function within the same CFC in the APPLICATION scope?
    primarykey
    data
    text
    <p>I am using ColdFusion 9.0.1.</p> <p>Let me start by stating that I may not be asking the right question. Since each function works independently and fails only when one function calls another, I am thinking that the problem is in how the function is called. </p> <p>I am creating an application variable that contains a structure. The structure contains the reference to an object, orders.cfc.</p> <pre><code>if (not isDefined("APPLICATION.AppInfo") or not isStruct(APPLICATION.AppInfo)) { APPLICATION.AppInfo = structNew(); APPLICATION.AppInfo.objOrders = createObject("component", "globaladmin.orders"); } </code></pre> <p>I am able to successfully access the methods in the orders.cfc like this:</p> <pre><code>OrderItemList = APPLICATION.AppInfo.objOrders.orderItemList(URL.Customer); </code></pre> <p>I have methods in the orders.cfc that call other methods in the order.cfc, kind of like this (faked for simplicity):</p> <pre><code>&lt;cffunction name="orderItemList"&gt; &lt;cfscript&gt; LOCAL.RandomNumber = getRandomNumber(); return LOCAL.RandomNumber; &lt;/cfscript&gt; &lt;/cffunction&gt; &lt;cffunction name="getRandomNumber"&gt; &lt;cfscript&gt; LOCAL.SomeNumber= randRange(0,10); return LOCAL.SomeNumber; &lt;/cfscript&gt; &lt;/cffunction&gt; </code></pre> <p>I get this error:</p> <pre><code>Entity has incorrect type for being called as a function. The symbol you provided getRandomNumber is not the name of a function. </code></pre> <p>I figured maybe I can't reference a function within the same CFC without creating an object first, so I do this:</p> <pre><code>&lt;cffunction name="orderItemList"&gt; &lt;cfscript&gt; LOCAL.RandomNumber = APPLICATION.AppInfo.objOrders.getRandomNumber(); return LOCAL.RandomNumber; &lt;/cfscript&gt; &lt;/cffunction&gt; </code></pre> <p>Then, I'd get this error:</p> <pre><code>Either there are no methods with the specified method name and argument types, or the method getRandomNumber is overloaded with arguments types that ColdFusion can't decipher reliably. If this is a Java object and you verified that the method exists, you may need to use the javacast function to reduce ambiguity. </code></pre> <p>How should I call a second function within the same CFC?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload