Cfthread not executing

I have the following simple cfthread tag

However, it doesn’t execute the .cfm file. The file runs fine if I use a browser to make it happen, but when I’m trying to run it as a background action, it doesn’t execute with this CFTHREAD. My bottom line is I need it to run immediately after someone places an order on my site and without me having to manually visit the .cfm page in a browser and without the customer having to manually see the .cfm page during their order process. I pass URL vars to make sure the .cfm page processes the order information. The page essentially sends out various emails to different recipients based on the URL vars I pass along.

Um… did you forget something between your first and second paragraph there?

Also, what is telling you that the code called via cfthread is not executing? If it’s that its expected result doesn’t happen, what if you add cflog/writelog code in that called cfm (perhaps at the start and end of its logic flow)? Do you see those?

If so, it IS executing: but somehow your expected result is NOT being generated.

If you don’t see the logging (but do see it when you call the cfm directly), then perhaps you’re getting an error–and perhaps you’re also having some error handling that’s keeping you from seeing such an error that’s happening.

But as Adam notes, if we saw your code we might see something else to explain your challenge.

“< cfthread action=“run” name=“emailresponse”>
< cfinclude template=“orders/order-confirmationMAIL.cfm?oid=#session.oid#&did=#session.did#”>
< /cfthread >”

To answer the question about knowing if it worked is what I mentioned originally in that the script is supposed to email using CFMAIL and no emails were sent using CFTHREAD but when I manually visit the script page in a browser it worked fine.

Are you willing to try simply adding the logging requested. It’s a couple of minutes effort that may yield useful diagnostics.

OK firstly, to include code here, either do it inline by surrounding it with single back-ticks (`), or

as a block

By surrounding the block with triple back ticks (```) on a separate line.

Now, to your problem.

orders/order-confirmationMAIL.cfm?oid=#session.oid#&did=#session.did# is a URL.

<cfinclude> take a file path (to a “template”, ie a CFML file). I admit the wording in the docs (<cfinclude> :: Lucee Documentation) is unhelpful / vague / unclear (CF’s are no better: cfinclude), but the parameter is template not url.

If you check your exception log (which should be an integral part of troubleshooting anything that is misbehaving, in the absence of an on-screen error), you will see an error to the effect that the template value is not a file path.

<cfinclude> is for grabbing a chunk of code from a separate file. It is not for making HTTP requests.

If you want to make an HTTP request, then that is <cfhttp> (<cfhttp> :: Lucee Documentation).

You might also want to look at runAsync (RunAsync() :: Lucee Documentation). <cfthread> is a bit of an old-fashioned approach to what yer doing here.

The most important take-away here is that you should be looking at your logs as a matter of course when things go wrong. Look for and understand on-screen errors first; then do the same with the logs. When something is wrong, don’t post something like “it doesn’t execute”; post with “I got this error, and…”. Although just examining the error and addressing what it says is usually enough to solve an issue yerself…