Reminder - stop using the old CFC-based tags in ColdFusion 11

This post is more than 2 years old.

Earlier last week I was helping someone diagnose a ColdFusion issue when I noticed he was using the old CFC-based tags in cfscript. Specifically:

httpService = new http();
httpService.setMethod("put");
httpService.setCharset("utf-8");
httpService.setUrl(someURL);
httpService.addParam(type="file",name="stuff",file="c:\inetpub\wwwroot\test.csv",mimetype="Content-type:text/csv");
httpService.addParam(type="formfield",name="filename",value="Test");
result = LOCAL.httpService.send().getPrefix();

Back around ColdFusion 9 I believe Adobe made CFCs to support a few different tags in cfscript. They were: cfcollection, cfdbinfo, cffeed, cfftp, cfhttp, cfimap, cfindex, cfldap, cfmail, cfpdf, cfpop, cfquery, cfsearch, cfstoredproc, cfstoredprocresult.

I used a few of these quite a bit, and in general they worked ok, but I ran into bugs from time to time. Surprisingly these CFCs are not encrypted. You can find them in an com.adobe.coldfusion folder under your server's CustomTags folder. Because they weren't encrypted, I actually wrote my own fixes from time to time.

But the point is - in ColdFusion 11, you should not be using any of these, and should be using the built-in support for tags in script. The documentation for this may be a bit hard to find. The feature as a whole may be found here: Script support for tags, but as far as I know, none of the wiki pages shows examples of this in regards to individual tags.

Adam Cameron does a good write up about some of the mistakes in Adobe's implementation. I don't agree they are quite as bad as he points out, but I strongly agree that "cf" should have been removed from the calls and the need to pass in a result argument should have been fixed. Maybe ColdFusion 12 will correct that. (Or Luccee. :)

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Andy Myers posted on 2/11/2015 at 12:21 PM

Hi Ray,

Is you example above what you're saying we *shouldn't* be using? Ie are you saying we should use the script version of cfhttp rather than "httpService = new http()", etc?

Comment 2 by daniel fredericks posted on 2/11/2015 at 12:21 PM

I did talk to you and Adobe about Adobe adding in the script examples in the docs, and they said they would...guess that was just to get me off their back...it is hard to teach people script if there are no examples in the actual docs...

Comment 3 (In reply to #1) by Raymond Camden posted on 2/11/2015 at 12:36 PM

Yes. If anyone else agrees it isn't clear (seems clear to me), I'll edit the post to make it more clear.

Comment 4 (In reply to #2) by Raymond Camden posted on 2/11/2015 at 12:37 PM

I wouldn't assume it was a lie per se - just probably a time thing. :)

Comment 5 (In reply to #3) by Andy Myers posted on 2/11/2015 at 12:46 PM

It was the title that threw me (mentions tags but its actually certain script constructs you're suggesting we avoid?)

Comment 6 (In reply to #5) by Raymond Camden posted on 2/11/2015 at 12:50 PM

Heh, yeah, I struggled with that actually.

Comment 7 (In reply to #6) by Andy Myers posted on 2/11/2015 at 12:52 PM

I follow now :) I just wanted to be sure. Thanks for clarifying.

I need to hunt down that folder you refer to and make sure i don't use any of these :)

Comment 8 (In reply to #7) by Raymond Camden posted on 2/11/2015 at 12:54 PM

This would be a good rule for the CFLint project too.

Comment 9 by Mike posted on 2/11/2015 at 6:07 PM

Luccee or Lucee?

Comment 10 (In reply to #9) by Raymond Camden posted on 2/11/2015 at 6:09 PM

Lucee. Sorry.

Comment 11 (In reply to #3) by Brad Wood posted on 2/11/2015 at 6:31 PM

I think it might help some people if you threw in a quick equivalent of the code sample using the new syntax. I know your blog isn't meant to be a how-to guide, but it might help clear up the difference.

Comment 12 (In reply to #11) by Raymond Camden posted on 2/11/2015 at 6:34 PM

Brad, I thought about doing that, but decided against it when I ran low on time this morning. It makes sense though. I'll try to post a follow up blog post later this afternoon with an example. I hate saying "Don't do X" without saying "Do Y instead."

Comment 13 by Raymond Camden posted on 2/12/2015 at 11:35 AM

For folks looking for an example (Brad Wood :), I posted this today: http://www.raymondcamden.co...

Comment 14 by Link Worx Seo posted on 4/22/2016 at 4:52 PM

Hay Ray, how you doing? Just been really tearing into cfscript and for some reason I can not get a recordcount to check the output of a sql statement. I keep trying to use the getPrefix(); because that is the function that gets the recordcount. I have tried using something like secObj.execute(sql='SELECT userlogin FROM security WHERE userlogin=#arguments.userlogin#');

and then result.getPrefix(); or result.getPrefix(secObj);

I can get the getPrefix(); to work in the writeDump(); but that is the only way so far. Got any good hints for me?

This is the

if(memresult.getPrefix(memObj) NEQ 0 OR secresult.getPrefix(secObj) NEQ 0)

statement I am trying to get the recordcount for. I even tried using the setName and then recordcount as in checkEmail.recordCount NEQ 0 etc...

Comment 15 (In reply to #14) by Raymond Camden posted on 4/22/2016 at 5:53 PM

Why are you using getprifx though? If you use queryExecute, the result object (the query) will have the recordcount.

Comment 16 (In reply to #15) by Link Worx Seo posted on 4/22/2016 at 8:00 PM

Okay, are you suggesting? secObj.execute(sql='SELECT userlogin FROM security WHERE userlogin=#arguments.userlogin#'); as in the .execute(); or is that a function of queryExecute(); I have not seen?

Comment 17 (In reply to #16) by Raymond Camden posted on 4/22/2016 at 8:04 PM

Not quite sure I understand you. When you do: x=queryExecute(...), the result, x, is a query. All queries in CF have a .recordCount property.

Comment 18 (In reply to #17) by Link Worx Seo posted on 4/22/2016 at 9:41 PM

I tried that already and it keeps showing the the variable is not defined or I end up getting a complex value error or construct error. Trying to place it in the if else statement. Same errors no matter what I try.

secObj = new query();
secObj.setDatasource('#application.dsn#');
username='#application.dbusername#';
password='#application.dbpassword#';
secObj.setcachedwithin(CreateTimeSpan(0, 0, 0, 0));
debug=true;
timeout=5;
secObj.setName('checkUsername');
secresult = secObj.execute(sql='SELECT userlogin FROM security
WHERE userlogin=#arguments.userlogin#');
secObj.addParam(name='userlogin', value='#arguments.userlogin#', cfsqltype='CF_SQL_VARCHAR');
checkUsername = secresult.getResult();
secmetaInfo = secresult.getPrefix();

if(x.recordcount NEQ 0 OR y.recordcount NEQ 0){
return (false);

Comment 19 (In reply to #18) by Raymond Camden posted on 4/22/2016 at 11:52 PM

Heh, you are missing the crucial part. queryExecute. Don't use the old CFC style version. That was the whole point of this article. :)

Comment 20 (In reply to #19) by Link Worx Seo posted on 5/3/2016 at 12:20 AM

Got this one solved. Thanks. Working on converting old cf tags to cfscript right now. On one of the other post from you and trying to determine the best route for it.

Comment 21 (In reply to #18) by shakeel posted on 12/2/2016 at 9:32 PM

the recordCount is actually inside the secMetaInfo.recordCount

Comment 22 (In reply to #21) by Link Worx Seo posted on 12/2/2016 at 10:00 PM

Thanks for the response, this was a question when I first started converting my website to cfscript. Got it covered now.