Thursday, August 2, 2012

CRM 2011 JS

// change CRM fields color to red = "#FF0000";
// Get picklist value
Xrm.Page.getAttribute("<field Schema name>").getValue();

// Get picklist selected text
Xrm.Page.getAttribute("<field Schema name>").getSelectedOption().text;

// Set picklist value
Xrm.Page.getAttribute("<field Schema name>").setValue("<set Int value>");
// Set picklist value to blank
Xrm.Page.getAttribute("<field Schema name>").setValue(null);
// Disable CRM field
Xrm.Page.getControl('<field Schema name>').setDisabled(true);
// set CRM field as required
Xrm.Page.getAttribute("<field Schema name>").setRequiredLevel("required");
// remove required level of the CRM form filed
Xrm.Page.getAttribute("<field Schema name>").setRequiredLevel("none");
// Hide CRM form Field
crmForm.all.<field Schema name> = 'none';
crmForm.all.<field Schema name> = 'none';

// force submit a field on save of the form
Xrm.Page.getAttribute("<Field Schema Name>").setSubmitMode("always");

// Set lookup value to a field
function SetLookupValue(fieldName, id, name, entityType) {
    if (fieldName != null) {
        var lookupValue = new Array();
        lookupValue[0] = new Object();
        lookupValue[0].id = id;
        lookupValue[0].name = name;
        lookupValue[0].entityType = entityType;


No comments: