0

I am submitting a form to a CFC which in turn invokes a method in a different CFC. The initial CFC will then send an e-mail to the user confirming its all done. Its a bit like this:

<cfcomponent>
<cffunction name="FinalDemand" access="remote">
<cfinvoke component="AnotherCFC" method="AddToAudit" argumentCollection="#Arguments#">
<!--- I need to wait for confirmation from AnotherCFC here before continuing --->
<cfset APPLICATION.SendMail.ThankYou()/>
<cfset var Success = true>
<cfreturn Success>
</cffunction>
</cfcomponent>

The AnotherCFC is doing an update to a database. I'd really like that method to be able to tell the calling CFC that its done its work. At the moment it just returns a boolean like the CFC above to say all went well. If it doesn't return the boolean then we know it went wrong.

Is this possible at all? I don't mind using JQuery to acomplish it if need be.

volume one
  • 6,800
  • 13
  • 67
  • 146
  • 1
    *I need to wait for confirmation from AnotherCFC here before continuing* Then do that ;-) Have both functions return true/false. Inside your function, capture the result of each call and react accordingly. do something... – Leigh Jul 25 '15 at 21:48
  • @Leigh can you give me an example? the other cfc also returns Success if it ran ok... how do I access that? – volume one Jul 25 '15 at 22:20
  • 3
    (Edit) Look at the [cfinvoke documentation](https://wikidocs.adobe.com/wiki/display/coldfusionen/cfinvoke). It has a returnVariable attribute for capturing the result of a function call into a variable. Then just it in a cfif like you would any other variable. Personally I find the `cfinvoke` syntax too bulky. My preference is to use `createObject()`. BTW, the cfinvoke call is *not* asynchronous. So it only returns control to your outer function when the AddToAudit method is finished. – Leigh Jul 25 '15 at 22:50
  • Do you mean bulky in terms how much code you have to write? Functionally, I thought CreateObject() / New() was the same as cfinvoke? – volume one Jul 25 '15 at 23:05
  • (Edit) Yes, the createObject/new syntax is sleaker and simpler IMO. Functionally, they do the same thing. It is mostly a matter of personal preference. These days I tend to prefer functions / cfscript over cfml ie tags in most cases. I find the syntax more elegant and it is more similar to other languages I am using. – Leigh Jul 26 '15 at 00:26

0 Answers0