Search This Blog

Friday, December 6, 2013

Get lookup value and also set into other field

var P_lookupValue = new Array();             
P_lookupValue[0] = new Object();
P_lookupValue[0].id = lookup.Id;
P_lookupValue[0].name = lookup.Name;
P_lookupValue[0].entityType = "lookup_name";
              
Xrm.Page.getAttribute("field_name").setValue(lookupValue); //set lookup value into field
Xrm.Page.data.entity.attributes.get("field_name").setSubmitMode("always"); // this line will set value if field is readonly

Enable and Disable Section

Xrm.Page.ui.tabs.get('tab_name').sections.get('section_name').setVisible(false);

Enable and disable fields

Xrm.Page.ui.controls.get("fieldname").setDisabled(false); // to enable field
Xrm.Page.ui.controls.get("fieldname").setDisabled(true);// to diable field

Get OptionSet Value

var optionSet = Xrm.Page.data.entity.attributes.get("optionsetname");
var optionSetValue = optionSet.getValue();