I was browsing the CRM 3.0 SDK the other day and ran across the following little tidbit:

Another improvement in scripting is that when you edit scripts, all formatting is retained to improve readability and maintainability.

Note   Use of /* … */ style comments is preferred in scripts.

If you didn't know, JavaScript supports two kinds of comments:

  • Block: /* */
  • Single Line: //

The above note caught my attention because I had just ran into an issue regarding the single line comments. I was using it to comment out the last line of an Event and I was getting JavaScript runtime errors. Removing the code that was commented-out stopped the errors.

That's when I realized that CRM 3.0 was removing trailing line breaks from the Event code and turning my Single-line Comment into a showstopper by including the trailing } in the comment and rendering the code "incomplete."

Consistent use of block comments will prevent code issues like this all together and I've had zero issues since I switched.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>