Archive for July, 2011

Audit issue after upgrade to CRM 2011


Recently when i upgrade my solution from CRM 4.0 to CRM 2011, I got an exception with CRM 2011 OOB “Audit” feature

(i.e., When I clicked on ‘Audit History’ link on one of the audit enabled entity’s CRM Form).

When I verify the Event Viewer (i.e., Application log) for error on the CRM Server, there was an error from ‘MSCRMWebService’ with below message.

The Web service Plug-In failed in Message : RetrieveRecordChangeHistory

Fix: –

This is a known issue with product and got fixed in CRM 2011 Roll up 2. So, install the role up 2 by downloading from below site

***Imp Note :- Even after the installation of Roll Up 2, the old records still shows the audit error. The roll up fix applies to the new records.

– You may still get Audit issues even after Roll Up 2, when you share a record Programatically  (i.e, Using plug-in’s). This issue has been fixed in Roll Up 4.

Hope It Helps 🙂

Machine hangs up when you put a ‘debugger;’ in jScript “OnChange” event

July 28, 2011 1 comment


While debugging a Jscript file ,Sometimes you may come across the situation where your machine gets hanged and it won’t even allow you start ‘Task Manager’ to kill the process.

 It happens, if you have the similar scenario

  • If you put a ‘debugger;’ command in ‘onChange’ event of Dropdown
  • If this is the only ‘debugger;’ command you put on the entire Jscript file
  • Enable script debugging in browser
  • Raise the ‘onChange’ event by changing dropdown value in the CRM Form


  • Always make sure to have one more ‘debugger;’ that called before hitting
    the ‘debugger;’ in ‘onChange’ event
  • Preferably always put a ‘debugger;’ in page ‘onLoad’ event when you
    want to debug the ‘onChange;’ event

Hope it helps 🙂

Sitemap “Settings groups” display as “Unknown” after an upgrade from CRM 4.0 to CRM 2011

Sitemap Upgrade Errors


Recently when i did an upgrade from CRM 4.0 to CRM 2011 by restoring CRM 4.0 DB, I got “Settings groups” display as “Unknown” (Refer image above)

– To fix this issue we have to modify the “Sitemap” by exporting it in a solution, and follow below steps

  • Open the “customizations.xml” file in text editor by extracting the solution zip folder
  • Replace <Group Id=”Business_Setting”> with <Group Id=”Business_Setting” ResourceId=”Menu_Label_Business” DescriptionResourceId=”Menu_Label_Business”>
  • Replace <Group Id=”System_Setting”> with <Group Id=”System_Setting” ResourceId=”Menu_Label_System” DescriptionResourceId=”Menu_Label_System”>
  • Replace <Group Id=”Customizations”> with <Group Id=”Customizations” ResourceId=”Homepage_SystemCustomization” DescriptionResourceId=”Homepage_SystemCustomization”>
  • Replace <Group Id=”ProcessCenter”> with <Group Id=”ProcessCenter” ResourceId=”Menu_Label_ProcessCenter”
  • Import the solution and publish

– Please refer for more details.

Adding “Notes” to the “Quote” progrmatically in CRM 2011

July 24, 2011 3 comments

//Instantiate ‘Entity’ and set the ‘LogicalName’ to “annotation”

Entity objNotes = new Entity();
objNotes.LogicalName = “annotation”;

//Set ‘Subject’ and ‘notetext (i.e.,Body)’ properties
objNotes.Attributes.Add(“subject”, ”—-Your Subject—”);
objNotes.Attributes.Add(“notetext”, “—Your notes text—”);

//Relate the note with ‘Quote’ using ‘EntityReference’

EntityReference refQuote = new EntityReference();
refQuote.LogicalName = “quote”;
refQuote.Id = quoteID;  //Quote GUID
objNotes.Attributes.Add(“objectid”, refQuote);

//Set “objecttypecode” property with “quote” objecttypecode (i.e.,1084)

//Refer for objecttypecode’s
objNotes.Attributes.Add(“objecttypecode”, 1084);

//Call CRMService ‘Create’ method


How to verify the log files for CRM installation issues

  • Open “Run” window (Ctrl+R)
  • Type “%APPDATA%\Microsoft\MSCRM\Logs\
  • You find the list of generated logs
  • Sort by “Last Modified Time” to get the latest .log file

Useful CRM 2011 JScript Syntaxes

XRM.Page Model diagram

Xrm.Page Model

Xrm.Page Model

The Xrm.Page object serves as a namespace object to consolidate three properties on the form:


Xrm.Page.context provides methods to retrieve information specific to an organization, a user, or parameters that were passed to the form in a query string. provides an entity object that provides collections and methods to manage data within the entity form.


Xrm.Page.ui provides collections and methods to manage the user interface of the form.


— “CRM Enity” Properties

  •   //Entity Name
  •                     //Record GUID
  •  Xrm.Page.ui.getFormType()                      //CRM Form Type (Integer)
    **Create (1), Update (2), Read Only (3), Disabled (4), Bulk Edit (6)

Get & Set Text Field


Get Lookup


Set Lookup

  •  var lookUpValue = new Array();
    lookUpValue[0] = new Object();
    lookUpValue[0].id = idValue;
    lookUpValue[0].name = textValue;
    lookUpValue[0].entityType = ‘{Entity_Name}’;
  • Xrm.Page.getAttribute(“primarycontactid”).setValue(lookUpValue);

— Clear the Lookup

  • To clear the lookup field value, set with ‘null’
  • Xrm.Page.getAttribute(lookupAttribute).setValue(null);

Option Set Properties

  •“new_country”).getOptions()   // All Options
  •“new_country”).getText()         // Option Label value
  •“new_country”).getValue()       // Selected option value

Hide/Show controls

  • Xrm.Page.ui.controls.get(“name”).setVisible(true/false)

Disable/Enable controls

  •  Xrm.Page.ui.controls.get(“name”).setDisabled(true/false)

Set Focus

  • Xrm.Page.ui.controls.get(“name”).setFocus();

Set field’s Requirement Level

  • Xrm.Page.getAttribute(“name”).setRequiredLevel(“none”);
  • Xrm.Page.getAttribute(“name”).setRequiredLevel(“required”);
  •  Xrm.Page.getAttribute(“name”).setRequiredLevel(“recommended”);

Set the label for the control

  •  Xrm.Page.ui.controls.get(“name”).setLabel(“Label Text”);

Set URL for IFrams/WebResource

  •  Xrm.Page.ui.controls.get(“IFrame/WebResource Name”).setSrc(“URL”);

Get Parent of current control

  •  Xrm.Page.ui.controls.get(“name”).getParent();

“Current User” & “Organization” details

  • Xrm.Page.context.getUserId()                     //Current User ID
  •  Xrm.Page.context.getOrgUniqueName() //Organization Name
  •  Xrm.Page.context.getServerUrl()              //Server URL
  •  Xrm.Page.context.getUserRoles()             //Role ID’s of current user

Check isDirty

  •  // Form is IsDirty
  •“new_name”).getIsDirty()  //Field is IsDirty

Save Form

  • function save(){;}

Save&close Form

  • function saveandclose(){“saveandclose”);}

Close Form

  • function close(){Xrm.Page.ui.close();}

Expand/Collapse Tabs

  • var myTab = Xrm.Page.ui.tabs.get(“{tab_name}”);
  • myTab.setDisplayState(“expanded”); // To expand tab
  • myTab.setDisplayState(“collapsed”); // To collapse tab

Hide/Show Tabs & Sections

  • var myTab = Xrm.Page.ui.tabs.get(“{tab_name}”);
  • myTab.setVisible(True/False);
  • var mySec = myTab.sections.get(“{sec_name}”);
  • mySec.setVisible(True/False);

— Get current form properties if you have multiple forms

  • var item = Xrm.Page.ui.formSelector.getCurrentItem();if (item != null) {var itemId = item.getId(); // Form GUID

    var itemLabel = item.getLabel(); // Form Name


  • Note – If your entity has only one form defined, “getCurrentItem()” will return null so the “item” become “null”

 —Look up window customizations (Unsupported) 

We can perform below customization actions on the lookup dialog window using JScript

 – Disable the “View Selection” dropdown

 – Hide the “New” button

 – Hide the “Search” textbox (i.e.,Quick search)

//To hide “New” button

crmForm.all.attr_name.AddParam(“ShowNewButton”, 0);

// To hide “New” button – Post UR 13

var lookupControl = Sys.Application.findComponent(“attr_name”);

if (lookupControl != null){

lookupControl._element._behaviors[0].AddParam(“ShowNewButton”, 0);


//To disable “View Selection” dropdown

document.getElementById(“{attr_name}”).setAttribute(“disableViewPicker”, “1”);

//To hide “Search” textbox

document.getElementById(“{attr_name}”).setAttribute(“disableQuickFind”, “1”);

After applying the script (i.e., After placing the above lines in form onload event), the lookup window looks as below

Customized lookup dialog

Customized lookup dialog

Quick Reference :-

Great post on the difference B/W CRM 4.0 syntaxes Vs CRM 2011 syntaxes

Issues while installing CRM 4.0 on Windows Server 2008 R2

Errors Screen

While installing CRM 4.0 on Windows Server 2008 R2 server we  will get errors mentioned in above screen

1)    To fix the issue  “Service cisvc was not found on computer XYZ”


  • This is because CRM 4.0 requires the old “Indexing  Service (CISVC)” , which was part of Windows Server 2003


To fix this,  we need to enable the Windows Server 2003 indexing service (cisvc) on current Windows  Server 2008 machine within File Server Role. (Follow below steps)

Enabling CISVC Indexing Service

  • Open “Server Manager”
  • Click on “Roles” link
  • Go to “File Server Role” tab and click on  “Add Roles” link
  • Check “Indexing Service” under “Windows Server 2003 File Services”

2)    To fix the “Service  msftesql was not found”

Reason: –

  • This error comes from conflict between installing Microsoft Dynamics CRM 4.0 with SQL Server 2008.
  • The “msftesql” is the “Microsoft SQL Server Full  Text Indexing Service” which has a different name under SQL Server 2008


  • Open “Registry” (Go to Run -> Regedit)
  • Navigate to “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services” on the tree
  • Rename ‘MSSQLFDLauncher’ Folder to ‘msftesql’
  • Restart the server
  • Go to “Services” (Run ->  Services.msc)
  • Start the “SQL Full-text Filter Daemon  Launcher (MSSQLSERVER)” service
  • Complete the CRM installation
  • Rename back msftesql Folder to  MSSQLFDLauncher (Follow step 1 – 3) 

3)    To fix the “Index was  outside the bounds of the array”

  • Configure “User  Account” which you have given while installing CRM  as service account for Report Server and  Analysis server
  • Instead of  above step, You can even give “Network Service Account” as service account  while installation