Disable MS D CRM Form Ribbon Buttons using Java Script on Form Load

Disable MS D CRM Form Ribbon Buttons using Java Script on Form Load.

For Eg. I am trying to disable SAVE , SAVE & NEW , SAVE & CLOSE buttons on Form Load Event

 

function DisableSaveSaveAndCloseSaveAndNewButtons() {

var TelephoneNumber = Xrm.Page.getAttribute(“telephone”).getValue();

if (TelephoneNumber != “” || TelephoneNumber != null) {
//Disable delete button
var Save = top.document.getElementById(“phonecall|NoRelationship|Form|Mscrm.Form.phonecall.Save-Large”);
var SaveAndClose = top.document.getElementById(“phonecall|NoRelationship|Form|Mscrm.Form.phonecall.SaveAndClose-Large”);
var SaveAndNew = top.document.getElementById(“phonecall|NoRelationship|Form|Mscrm.Form.phonecall.SaveAndNew-Medium”);

Save.disabled = true;
SaveAndClose.disabled = true;
SaveAndNew.disabled = true;
Xrm.Page.ui.refreshRibbon();
}
}

 

Cheers,

Set Default View in Party Lookup (Regarding)Type in MS CRM 2011

Set Default View in Party Lookup (Regarding)Type in MS CRM 2011

Use the following code to set the Regarding Lookup to Incident instead of Account and set the default view.

document.getElementById(“regardingobjectid”).setAttribute(“defaulttype”, “112”);
Xrm.Page.getControl(“regardingobjectid”).setDefaultView(“Guid of the View to be displayed”);

 

Cheers,

Default Regarding Lookup to Incident in CRM 2011 in Email and Phone Call

Default Regarding Lookup to Incident in CRM 2011 in Email and Phone Call

Use the following code to set the Regarding Lookup to Incident instead of all party list types.

document.getElementById(“regardingobjectid”).setAttribute(“defaulttype”, “112”);

(or)

crmForm.all.regardingobjectid.setAttribute(“defaulttype”, “112”);

you may use either type of codes . . Working fine.

if you disable all the types and show the only one entity type use the following code on page load

document.getElementById(“regardingobjectid”).setAttribute(“defaulttype”, “112”);
document.getElementById(“regardingobjectid”).setAttribute(“lookuptypes”, “112”);
document.getElementById(“regardingobjectid”).setAttribute(“lookuptypeIcons”, “/_imgs/ico_18_112.gif”);

or

using CRM Form Code is as Follows

crmForm.all.to.setAttribute("defaulttype", "112");
crmForm.all.to.setAttribute("lookuptypes", "112");
crmForm.all.to.setAttribute("lookuptypeIcons", "/_imgs/ico_18_112.gif");

You may achieve same functionality using JQuery is as follows and refer to page JQuery 1.4.1 and json2 files in your Form Properties

$("#regardingobjectid").attr("defaulttype", "112");
    $("#regardingobjectid").attr("lookuptypes", "112");
    $("#regardingobjectid").attr("lookuptypeIcons", "/_imgs/ico_18_112.gif");

Cheers,