0
votes

Question: I have a CFM calling my CFC on the cfform action line:

In my CFC, I have output="false". I am needing the record count sent back to my CFM. When I run my CFM and enter the form info my queries are running successfully, but it is not coming back to my CFM so I can display the proper messages. I just get the CFC page with my record count. Any suggestions? Thanks!

2
Can you post some code?? - jk.
As it is now, here is my <cfform line. - Mia
<cfform line: <cfform action="customers.cfc?method=ModifyCustomers" method="post">. Is correct? Sorry, I am new at this! - Mia
I'd suggest something along the lines of what @Billy Cravens suggested below. Is there any particular reason you have to be submitting the form to a CFC versus submitting it a regular .cfm page that simply calls a CFC? - charliegriefer

2 Answers

3
votes

Since there's no code, making a few assumptions here about how you're doing things ....

Don't point to the CFC, point to a CFM page in your <cfform>. (If you omit the action, it'll point back to itself.. I like self-referencing form pages)

In your CFC, return the result struct from your query:

<cfquery datasource="#ds#" name="myQuery" result="myResult">
    INSERT INTO myTable .....
</cfquery>

Then either return that entire struct, or just myResult.recordCount:

<cfreturn myResult.recordCount>

Then in your CFM page, you'll access it like so (assuming you're using <cfscript>; similar if you're doing tag-based):

recordsAdded = createObject('component','myFolder.myCFC').insertMethod(form);
0
votes

I changed the cfform line to this: ....rest of my form

then added these lines to see if the form was submitted and what action is:

<!--- create object for cfc --->

But now, my query is not running....