Thursday, June 24, 2010

Crm 4.0 timeouts with large custimization imports

The fellows at Microsoft have a great write up on some ideas to try to resolve this problem. See this link.

Nice work Microsoft!

Dynamically load JavaScript file

Hello Gang,

Recently I needed to figure out how to load a JavaScript file into the DOM during the onload event. I was working with a form in CRM 4.0 and was tired of cutting and pasting the same .js code. Here's how I did it:

/*Load script for ajax calls*/
var scriptLoaded = false;
var TIMER= 0;

crmForm.Neudesic_LoadScript = function(scriptToLoad) {

var head= document.getElementsByTagName("head")[0];
var script= document.createElement("script");
script.type= "text/javascript";
script.src= scriptToLoad;
/*make sure the script gets loaded before it gets called*/
script.onreadystatechange= function () {
if (this.readyState == "complete" || this.readyState == "loaded") {
scriptLoaded = true;
crmForm.Neudesic_IsScriptLoaded = function() {
if(scriptLoaded) {
clearInterval (TIMER);/*this will stop the loop*/

Here's the code for calling it:
if(crmForm.FormType == 1 || crmForm.FormType == 2) {
/*load script*/
/*check to see if script is loaded*/
TIMER = setInterval ("crmForm.Neudesic_IsScriptLoaded()", 500);
Here's a great link for more information on this topic. It covers writing some JavaScript that could do this for multiple files. Basically you need to include some arrays that hold the TIMERs and the URLs that need loaded.

Have fun,


Thursday, June 3, 2010

Hiding tabs in CRM 4.0

Here's how you hide a tab on a CRM 4.0 form.

Define the function to hide the tab (place in the form's onload event):

/*hide tab*/
crmForm.Neudesic_HideTab = function(tabName) {
document.getElementById(tabName).style.display = "none";
Now call the function from the onload event of the form:

if(crmForm.FormType == 1 || crmForm.FormType == 2) {
/*hide tab*/
The tabs across the top of the form have the following naming convention: tabXTab where X is the number of the tab (starting with zero). So if you wanted to hide the first tab you would use tab0Tab as the name. If you wanted to hide the second tab you would use tab1Tab, etc.

Have fun...

Tuesday, June 1, 2010

Setting Crm 4.0 object attributes to null

Just got a call from a client on how to do this. CRM 4.0 attributes need to have to properties set:
  1. IsNull
  2. IsNullSpecified

CrmDateTime dt = new CrmDateTime();
dt.IsNull = true;
dt.IsNullSpecified = true;
CrmMoney cm = new CrmMoney();
cm.IsNull = true;
cm.IsNullSpecified = true;

Happy coding...