11

I have a test.cfm page and would like to call a cfc with a <cffunction> named errorEmail using <cfscript> from that page (test.cfm) instead of

<cfinvoke component = "#cfcPath#" method = "errorEmail" returnVariable = "myReturn" 
    description = "get list of projman">
</cfinvoke> 

I have tried:

<cfscript>
   errorEmail(cfcPath);
</cfscript>
4

1 に答える 1

13

I do this all the time.

1) Create the object:

<cfscript>
    // CREATE OBJECT 
    TheCFC = createObject("component", "thecfc");
</cfscript>

2) Call the function:

<cfscript>
    // CALL THE FUNCTION
    SomeVariable = TheCFC .theFunction();
</cfscript>

Your version would look like this

<cfscript>
    // CREATE OBJECT 
    TheObject = createObject("component", "cfcPath");
    // CALL THE FUNCTION
    myReturn = TheObject.errorEmail();
</cfscript>
于 2012-07-11T16:22:08.890 に答える