Home > CRM, JavaScript > JScript changes from CRM 4.0 to CRM 2011

JScript changes from CRM 4.0 to CRM 2011

So you want to port you CRM 4.0 Java script changes to CRM 2011. Well here is a table that can help.

Request To

CRM 4.0

CRM 2011

Set Field Value

crmForm.all.CRMFieldSchemaName.DataValue=Value

Xrm.Page.getAttribute(CRMFieldSchemaName).setValue(Value);

Get Field Value

crmForm.all.CRMFieldSchemaName.DataValue

Xrm.Page.getAttribute(CRMFieldSchemaName).getValue();

Set requirement fields

For No Requirement——————————

Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“none”);

crmForm.all.CRMFieldSchemaName.setAttribute(“req”, 0);

Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“required”);

crmForm.all.CRMFieldSchemaName_c.className = “n”;

Xrm.Page.getAttribute(“CRMFieldSchemaName”).setRequiredLevel(“recommended”);

For Recommended——————————

 

crmForm.all.CRMFieldSchemaName.setAttribute(“req”, 1);

 

crmForm.all.CRMFieldSchemaName_c.className = “rec”;

 

For Required——————————

 

crmForm.all.CRMFieldSchemaName.setAttribute(“req”, 2);

 

crmForm.all.CRMFieldSchemaName_c.className = “req”;

 

Enable/Disable fields

crmForm.all.CRMFieldSchemaName.Disabled = true;

Xrm.Page.getControl(“CRMFieldSchemaName”).setDisabled(false);

crmForm.all.CRMFieldSchemaName.Disabled = false;

Xrm.Page.getControl(“CRMFieldSchemaName”).setDisabled(true);

Hide fields

crmForm.all.CRMFieldSchemaName.style.Display = ‘none’;

Xrm.Page.ui.controls.get(“CRMFieldSchemaName“).setVisible(false);

crmForm.all.CRMFieldSchemaName _c.style.Display =’none’;

Show fields

crmForm.all.CRMFieldSchemaName.style.display = ‘block’;   OR

Xrm.Page.ui.controls.get(“CRMFieldSchemaName“).setVisible(false);

crmForm.all.CRMFieldSchemaName.style.display = ‘inline’;

Get Pick list Value

crmForm.all.CRMFieldSchemaName.DataValue

Xrm.Page.getAttribute(“CRMFieldSchemaName”).getSelectedOption().text;

Set Pick list Value

crmForm.all.CRMFieldSchemaName.DataValue= value;

Xrm.Page.getAttribute(“CRMFieldSchemaName”).setValue(parseInt(Value));

Get Lookup value

var lookupItem = new Array;

var lookupItem = new Array;

lookupItem = crmForm.all.CRMFieldSchemaName.DataValue;

lookupItem = Xrm.Page.getAttribute(CRMFieldSchemaName).getValue();

if (lookupItem[0] != null)

if (lookupItem[0] != null)

{

{

 alert(lookupItem[0].name);

 alert(lookupItem[0].name);

 alert(lookupItem[0].id);

 alert(lookupItem[0].id);

 alert(lookupItem[0].typename);

 alert(lookupItem[0].entityType);

}

}

Set Lookup value

var lookupData = new Array();

Xrm.Page.getAttribute(“CRMFieldSchemaName”).setValue( [{id: idValue, name: textValue, entityType: typeValue}]);

var lookupItem= new Object();

Or

   lookupItem.id = ‘guid‘;

var value = new Array();

   lookupItem.typename = ‘entityname‘;

value[0] = new Object();

   lookupItem.name = ‘TextVal‘;

value[0].id = guid‘;

   lookupData[0] = lookupItem;

value[0].name = TextVal‘;

   crmForm.all.CRMFieldSchemaName.DataValue = lookupData;

value[0].entityType = typeValue;

 

Xrm.Page.getAttribute(“fieldName”).setValue(value);

 

 

Tab Hide

crmForm.all.tabIndexTab.style.visibility = “hidden”;

Xrm.Page.ui.tabs.get(Tab Index).setVisible(false);

Xrm.Page.ui.tabs.get(Tab Index).setVisible(true);

OR

Xrm.Page.ui.tabs.get(Tab Name).setVisible(true);

Advertisements
Categories: CRM, JavaScript Tags:
  1. Anonymous
    April 14, 2011 at 4:42 pm

    Great information… It provide quite helpful to me in translating my CRM 4.0 java script.

  2. Rohit
    August 18, 2011 at 6:51 am

    Excellent job……

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: