Create a Random List in ColdFusion

A post on how to randomise a list with ColdFusion: http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/create-a-random-list-in-coldfusion-38

*update*

I’ve found a comprehensive post by Ben Nadel about this:
http://www.bennadel.com/blog/219-Randomly-Sorting-A-ColdFusion-List.htm 

Fusebox powered blog

I’ve finally got round to writing my own blog web app. It is built on Fusebox 5.5, using the new implicit cfc based circuits instead of the traditional XML method.

You can see my new blog at: www.aliaspooryorik.com/blog/

So, why did I write my own blog software? Well, I’m a ColdFusion developer and I wanted to try out the new no xml approach to writing Fusebox apps in a real world situation. If anyone wants a Fusebox based blog or just wants to see a Fusebox application written without XML, then let me know. If there is any interest then I’ll be happy to release it a a free and open source project on riaforge.

Fusebox 5.5 Application.cfc and webservice bug

I just discovered a bug in Fusebox 5.5.1. You can replicate it by downloading the sample application from Fusebox.org.

If you create a CFC at the same level as your Application.cfc and call it as a webservice, it fails on line 32 of Fusebox.Application.cfc with the message

"Variable FORM is undefined. "

I solved this by changing the code in Fusebox5.Application.cfc to:

<cfif StructKeyExists(Variables, "URL")>
  <cfset structAppend(attributes,URL,true) />
</cfif>
<cfif StructKeyExists(Variables, "form")>
  <cfset structAppend(attributes,form,true) />
</cfif>

* Update *

Sean Corfield has now raised a ticket (#330) for this and added the fix to the Core files. He also spotted another scenario where this might occur. For now you need to download the latest trunk/corefiles/Application.cfc file from the SVN if you have the same problem until Fusebox 5.6 is released.

Using CharIndex to get a SubString

If you need to extract part of a string based on the index of a character in SQL, then you can use the CharIndex function and the Substring function. This works the same as the Find & Mid functions in ColdFusion and IndexOf in JavaScript.

For example  the order_deliverycountry field holds values in the format ‘UK|United Kingdom’. To get the ‘UK’ part use the following code:

select SubString([Orders].order_deliverycountry, 1, CharIndex('|', Orders.order_deliverycountry) - 1) as CountryCode
from [Countries]