Prior to ColdFusion 9, it was not always easy to <cfdump /> a variable when using <cfscript />.
Solution
Create a function or a utility component which you can then call from cfscript. Using the function, you can pass in "true" to stop the code execution anywhere you place the function call. This is useful for debugging chunks of code with a lot of conditional logic.
When passing a list into a query, and the the list contains STRING data types, each value must be surrounded with single quotes. Using <cfqueryparam /> the list can be formatted on the fly to adhere to this constraint in SQL.
Solution
Using <cfqueryparam /> in all ColdFusion queries is considered best practice for both preventing SQL injection attacks and improving query execution. Not only this, but you can use this tag to format the data without any extra string formatting functions.
I am working in a multi application environment.
Recently I discovered a problem - when other applications hit my warehouse database, they insert some HTML tags, java-scripts.
Those data are displaying in my system as report format in HTML, so the tags and scripts data are affecting my site.
So, I started doing HtmlEditFormat() everywhere to protect my site, but I have almost a 1000 reports.
It was a very bad task for me, so I tred to build up a function to do the job quickly without using HtmlFormat() function everywhere and without changing my warehouse data because all that data is valid.
Solution
That’s why I created an automated function which will refine data without modifying data in the database.
It returns a query with any string values sanitized by HTMLEditFormat. Values of the type varchar,char,nvarchar,text,ntext are modified.
How can I sort an array of objects with ColdFusion?
Solution
ColdFusion's struct data-type helps simplify sorting an array of objects (or other complex data-types). We will build a new struct where the key is the value we need to sort. We will also ensure that duplicate values are not lost in the process.
The rest of the internet is in love with using REST to deliver web services instead of SOAP. How can I implement RESTful web services with ColdFusion?
Solution
Don't roll your own! Depending on your preference, use Taffy if you prefer a convention-based solution or PowerNap if you prefer a configuration-based solution. Also, frameworks like Coldbox and Mach-ii have built-in endpoints for RESTful web services too.
How can I use ColdFusion to draw a complex shape and then add text to that shape.
Solution
Using ColdFusion built in functions we will take a set of x,y coordinates and create an image and then place text on that image. We will use ImageNew, ImageDrawLines, and ImageDrawText amongst others. Keep in mind the image functions are available in ColdFusion version 8.0 or higher.