Skip to main content
Participant
July 14, 2010
Question

Is it possible to use a cfc return value use another cfc

  • July 14, 2010
  • 1 reply
  • 464 views

hi friends,

Help me,Is it possible to use a cfc return value use another cfc.give example

regards,

welcomecanv

This topic has been closed for replies.

1 reply

Sreeindia
Participating Frequently
July 14, 2010

Hi

Is it like you want to access another cfc from one cfc . I have this example which works. Hope you will get an idea with this.

1. cfctest.cfm

<cfset testobj = #createObject("component", "znewtest")#>
<cfdump var="#testobj.myFunction("hi")#">

2. znewtest.cfc

<cfcomponent>
    <cffunction name="myFunction" access="public" returntype="string">
        <cfargument name="myArgument" type="string" required="yes">
        <cfset myResult="foo">
        <cfset testobj = #createObject("component", "znewtest2")#>
        <cfreturn testobj.myFunction2("testargument")>
    </cffunction>
</cfcomponent>

3.znewtest2.cfc

<cfcomponent>
    <cffunction name="myFunction2" access="public" returntype="string">
        <cfargument name="myArgument" type="string" required="yes">
        <cfset myResult="fooss">
        <cfreturn myArgument>
    </cffunction>
</cfcomponent>

Above code is not an optimized one. Just posted as it was readily available. As you can see  znewtest.cfc (which is accessed in cfctest.cfm) is accessing myFunction2 of znewtest2.cfc. Hope this may be helpful to you. Let me know

Sreekar