CFSCRIPT Snippets and Hints
Some useful cfscript snippets and syntax. Many of these originated from Pete Freitag's CFSCRIPT Cheat Sheet: https://www.petefreitag.com/cheatsheets/coldfusion/cfscript/
Transaction Integrity Protection
Instructs the database management system to treat multiple database operations as a single transaction. Provides database commit and rollback processing.
Loops
Simple Loop
While Loop
Do / While Loop
For / In Loop
The for/in loop can be used to loop through queries, structures, or arrays
If / Then / Else
Switch Statement
NOTE: If your switch statement executes multiple case
conditions, then you likely don't have a break command at the end of the case
conditions. Don't forget to have break;
as your last line for all case conditions (doesn't apply to the default
condition).
Comments
Comments are done the same way a JavaScript: use //
for single line comments and /* */
to encompass multi-line comments. Do not use CFML comment markers: <!--- --->
Try / Catch / Throw
Last updated
Was this helpful?