Tips and tricks when using Microsoft Dynamics CRM 4.0
When you use Microsoft Dynamics CRM 4.0 in a development project, you have to think about a lot of things that you don't
think of when doing normal .Net development. Here are some random tips and tricks to help you success in you CRM development :
1. Don't write you JavaScript code directly on the CRM. Write it on .js files.
When you write JavaScript in the ISV.Config file or on the OnSave, OnLoad and OnChange methods, the CRM starts to behave abnormaly.
Half of the time the JavaScript will simply just not be brought to the client-side.
Write .js files that you will include on your aspx pages with a HttpModule to inject script include tags at runtime inside the <head> tag.
2. Write a lot of helper classes (JavaScript)
Because barely everything you do by JavaScript in the CRM is considered a hack, the minimum you can do if you absolutely want to
use this anyway is to encapsulate that hack in some clean methods that you developpers will call. By doing this you simplify the
life of all you developpers and you have centralized methods that can be easily modified if the DOM changes (by a CRM fix or patch).
3. Never delete your entities
If you do so, and then you reimport the entity with the XML customization file, you will get some fatal errors when accessing that entity.
4. Never delete the built-in security roles
If you delete them, you will not be able to add new entities... yes the CRM must have something hard-coded in it !
5. Always use the CrmService web reference that ships with the SDK.
Never reference a custom CrmService. Also, have a common class
that can give you the CrmService web reference after setting the CrmAuthenticationToken, the URL and the credentials.
If you use your own CrmService reference you will certainly have casting problems if in some case you use the GetCrmService() method
in plug-ins. By always using the SDK CrmService web reference you will never have problems. Also, the web reference is huge (about 3MB),
so you don't want a lot of DLLs to be that size.