Advertisements

Archive

Archive for August, 2011

Solution with Plug-Ins import error in CRM 2011

August 23, 2011 1 comment

Hi,

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=1.0.0.0, 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 🙂

Advertisements

Type-cast OData Service Datetime field in crm 2011

August 21, 2011 10 comments

Hi,

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));
                        dateValue.setDate(dateValue.getDate());
                        Xrm.Page.data.entity.attributes.get(“{fld_name}”).setValue(dateValue);

Hope it helps 🙂

Solution import error in CRM 2011

Hi,

Solution import error

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

Reason:-

  1. Let’s assume you have a solution “XYZ.zip” with 3 files (i.e., [Content_Types].xml, Customizations.xml & Solution.xml)
  2. Extract the “XYZ.zip” 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 “XYZ_new.zip”
  6. Try to Import the “XYZ_new.zip” as solution and you would get “Import solution error”

Fix:-

  • 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 “XYZ_new.zip”
    • Import  the zip
    • Get the “Imported successfully” message

Hope it helps 🙂

Submit disabled field using Jscript in CRM 2011

Hi,

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

Xrm.Page.getAttribute(“{fld_id}”).setValue(“{fld_value}”);

Xrm.Page.getAttribute(“{fld_id}”).setSubmitMode(“always”)

Hope it helps 🙂

Sub Grid Refresh Event – CRM 2011

August 13, 2011 3 comments

Hi,

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) {
subGrid.attachEvent(“onrefresh“,fnGridRefresh);

}

}

//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

Hi,

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

Hi,

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)){

control.setDisabled(truefalse);

}

});

}

How do I call this?

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

Hope it Helps 🙂