So today I got a fun email. One of our web service tools stopped working suddenly and was returning the error message "Variable FORM not defined". This struck me as odd, because as far as I knew, the FORM scope should always be in existence.

After doing a little reading I learned this isn't always the case. It turns out that when rendering a WSDL address, the FORM scope never exists. This means that anytime you use either an optional form element or directly reference form, it MUST be explicitly defined somewhere in your page. This should also be taken into account if you are still using application.cfm as, of course, this file will be part of your WSDL files source code.

As a rule of thumb, one should never expect a specific scope to exist in application.cfm/application.cfc, since it can be used across all page rendering views. Additionally, different scopes can be available at different points in the rendering of a file. An obvious example being during OnApplicationStart. At this point in the page rendering, SESSION isn't yet available, however APPLICATION is.

Remember: Always scope your variables, not just because of the above information, but also because it can become very cumbersome to attempt to figure out the exact scope of a variable once it's deep in code.