Archive for August, 2011

Solution with Plug-Ins import error in CRM 2011

August 23, 2011 1 comment


You may get below error, when you try to import solution with Plug-in’s (or) registering a Plug-In using Plug-In registration tool

Action failed for assembly ‘assemblyname,Version=, Culture=neutral, PublicKeyToken=c79c3c28c5ba3ec0′: Assembly must be registered in isolation.

Reason :-

  • The User  who is trying to register is not a  “deployment administrator”

Fix :-

  • Add User as “deployment administrator” by following below steps
  • Open “Deployment Manager” tool
  • Under “administrator’s” tab, Right click and add current user
  • Reset IIS

Hope it Helps 🙂

Type-cast OData Service Datetime field in crm 2011

August 21, 2011 10 comments


When you read any CRM DateTime value using OData Service, the value comes in /Date(1314763200000)/ format, which we can’t directly set to DateTime field.

Reason :-

  • OData parses data in “Edm.DateTime” type
  • <d:new_StartDate m:type=”Edm.DateTime”>2011-08-18T04:00:00Z</d:IBT_StartDate>

How to Type Cast to DateTime :-

  • Use below code to type cast OData DateTime type (i.e., Edm.DateTime) to CRM DateTime
  • var dt = ODataEntity.results[0].new_StartDate;
                        dt = dt.replace(“/Date(“, “”);
                        dt = dt.replace(“)/”, “”);
                        var dateValue = new Date(parseInt(dt, 10));

Hope it helps 🙂

Solution import error in CRM 2011


Solution import error

Sometimes you may get above error screen, when you try to import the “Solution”.


  1. Let’s assume you have a solution “” with 3 files (i.e., [Content_Types].xml, Customizations.xml & Solution.xml)
  2. Extract the “” to “XYZ_new” folder
  3. Do some customization changes (i.e., Add few buttons to Ribbon) to “Customizations.xml”
  4. Save the changes
  5. Zip the “XYZ_new” folder to “”
  6. Try to Import the “” as solution and you would get “Import solution error”


  • Always zip the files from root level not from folder level
    • i.e., When you make changes to solution files (Refer step 3 & 4) don’t zip “XYZ_new” folder, instead follow this step
    • open “XYZ_new” folder and select files (Ctrl + A) and zip the files to “”
    • Import  the zip
    • Get the “Imported successfully” message

Hope it helps 🙂

Submit disabled field using Jscript in CRM 2011


Below is the syntax to submit the disabled field value using JScript.



Hope it helps 🙂

Sub Grid Refresh Event – CRM 2011

August 13, 2011 3 comments


Sometimes we may need to refresh Parent form, when we Add/Remove records from sub grid (i.e., On Subgrid Refresh). We can achieve this with below steps

Grid Refresh Event

  • Get the “subgrid” id (i.e., Name of the subgrid, we can get it from either ‘Form customization’ or using IE Developer Tool)
  • In parent form, onload() function attach ‘onrefresh’ event to “Subgrid”

 function Form_onload() {
//Set Action on subgrid Refresh
var subGrid = document.getElementById(“{Subgrid ID}“);
if (subGrid) {



//This function fires on subgrid refresh

function fnGridRefresh(){

alert(“Grid refreshed!!!!”);


Hope it helps 🙂

Get Parent Record Id from child record form + crm 2011

August 12, 2011 1 comment


When you create/update a record form Associated view of Parent record, below is the JScript to “Get Parent Record Id from child record form”.

//Get Parent Record Id
var parentRecordID = GetUrlParameter();
parentRecordID = parentRecordID .substring(3, parentRecordID .length – 3);

function GetUrlParameter() {
var id = “”;
var name = “_CreateFromId”;

name = name.replace(/[\[]/, “\\\[“).replace(/[\]]/, “\\\]”);
var regexS = “[\\?&]” + name + “=([^&#]*)”;
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);

if (results == null) {

} else {
id = results[1];
return id;

How do i use this?

In child record FormLoad, Call this method

  •     var parentRecordID = GetUrlParameter();
  •     parentRecordID = parentRecordID .substring(3, parentRecordID .length – 3);
  • alert(“My Parent Record Id – “+parentRecordID  );

Hope it helps 🙂

Disabling form in CRM 2011


Here is the Jscript code to disable the CRM Form (i.e., Fields on the form)

function doesControlHaveAttribute(control){

var controlType = control.getControlType();

return controlType != “iframe” && controlType != “webresource” && controlType != “subgrid”;


function disableFormFields(truefalse){

Xrm.Page.ui.controls.forEach(function(control, index) {

if (doesControlHaveAttribute(control)){





How do I call this?

  • To disable Form  – disableFormFields(true)
  • To Enable Form  –  disableFormFields(false)

Hope it Helps 🙂

Handling Tab click event in CRM 2011


We can fire our own Jscript function on CRM tab click. Below are the steps

 How to get ID of Crm Form Tab :-

  • Get the ID of the ‘Tab’, using IE browser Developer Tool (i.e., Click F12)  (See image above)

Code :-

  • Attach “onclick” event handler on page ‘OnLoad’ method

function Form_onload() {
//Attach ‘onclick’ event handler to “Tab”
var linkGeneral = document.getElementById(“tab0Tab”);   //’tab0Tab’ is the ID of ‘General tab’
if (linkGeneral) {
linkGeneral.attachEvent(“onclick”, tab_onclick);



Function tab_onclick(){

//This function fires on Tab Click;

//Write your code


Hope it helps 🙂

Disabled fields in Bulk Edit Form – CRM 2011

August 8, 2011 3 comments


In CRM, We can edit multiple records (i.e., Bulk Edit) at a time. To do bulk edits we have to follow below steps

  • Select multiple records from the view (or) Associated view
  • Click on “Edit” button on the Ribbon

– In CRM 4.0 and older UR’s of CRM 2011, once you get the Bulk Edit CRM Form, you would notice couple of fields on the form is in disabled state and you wonder why?


  • Fields with “onchange” event will be in disabled state on Bulk Edit Form in CRM 4.0 and older roll up’s of CRM 2011.
  • With latest UR’s of CRM 2011, by default fields are in enabled state however the scripts associated to fields onchange event are disabled.
  • This is because for multiple records, CRM won’t be able to trigger the OnChange event and take the defined action in OnChange Jscript
  • In simple words, By Default Form and field events are disabled for the bulk edit form.

To enable a field (event) in Bulk Edit Form:-

We can enable the field onchange event by changing entity customization


  • Export the entity as a solution
  • Open “customizations.xml” file using visual studio
  • Navigate to <events> node of the field and set “BehaviorInBulkEditForm” to “Enabled”
  • Import back the solution (See below for the node)
  • <events><eventname=onchangeapplication=falseactive=falseattribute=“{your_attributename}BehaviorInBulkEditForm=Enabled>
  • “BehaviorInBulkEditForm” has below 3 options
    • Enabled  –  If you use this value, the field is enabled. Additionally, the code for the event is run when the event is called.
    • Disabled – If you use this value, the field is disabled.
    • EnabledButNoRender – If you use this value, the field is enabled. However, the code for the event is not run when the event is called.
  • Refer this useful link (KB) on Bulk Edit

Hope it Helps 🙂