-
Dynamics CRM 3.0 Client-side Programming: Commenting Your Code
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.
Customization, Dynamics CRM 1,456 views -
Dynamics CRM 3.0 Client-side Programming: DefaultValue
I was experimenting with the form control property .DefaultValue last night and found, much to my surprise, that it doesn't work.
From the CRM 3.0 SDK:
{Field}.DefaultValue
Get/set property.
Specifies the default value for the field.
Ideally, you would put the following code into the Form OnLoad event:
/* if the form type is Create */
if(crmForm.FormType == 1)
crmForm.all.new_myfield.DefaultValue ='Purple';
But, as I mentioned .DefaultValue doesn't work, so use the following:
/* if the form type is Create */
if(crmForm.FormType == 1)
crmForm.all.new_myfield.DataValue ='Purple';
Customization, Dynamics CRM 1,000 views



