Archive

Posts Tagged ‘CRM 4.0’

JScript changes from CRM 4.0 to CRM 2011

April 14, 2011 2 comments

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:
%d bloggers like this: