2014年12月30日 星期二

CRM 2011 Hide Custom Ribbon Button in JavaScript

CRM 2011 Hide Custom Ribbon Button in JavaScript

↓↓↓


JavaScript:
function OnLoadForm()
{
    HideApprovalButton();
}
function HideApprovalButton()
{
    var btnApprove=top.document.getElementById("quote|NoRelationship|Form|Mscrm.Form.quote.MainTab.Management.Approve-Large");
    var btnReject=top.document.getElementById("quote|NoRelationship|Form|Mscrm.Form.quote.MainTab.Management.Reject-Large");
    btnApprove.style.display='none';
    btnReject.style.display='none';
}

Other Sample(Ref web)
function HideRibbonControl(formName) 
{
    var saveButtonID = formName + "|NoRelationship|Form|Mscrm.Form." + formName + ".Save-Large";
    var saveandcloseButtonID = formName + "|NoRelationship|Form|Mscrm.Form." + formName + ".SaveAndClose-Large";
    var saveandnewButtonID = formName + "|NoRelationship|Form|Mscrm.Form." + formName + ".SaveandNew-Medium";
    var deactivateButtonID = formName + "|NoRelationship|Form|Mscrm.Form." + formName + ".Deactivate-Medium";
    var deleteButtonID = formName + "|NoRelationship|Form|Mscrm.Form." + formName + ".Delete-Medium";
    var approveButtonID = formName + "|NoRelationship|Form|Mscrm.Form." + formName + ".Approve-Large";

    HideARibbonButton(saveButtonID);
    HideARibbonButton(saveandcloseButtonID);
    HideARibbonButton(saveandnewButtonID);
    HideARibbonButton(deactivateButtonID);
    HideARibbonButton(deleteButtonID);
    HideARibbonButton(approveButtonID);
}
function HideARibbonButton(nameOfButton) 
{
   var btn = window.top.document.getElementById(nameOfButton);
   var intervalId = window.setInterval(function () {
       if (btn != null) {
           window.clearInterval(intervalId);
           btn.disabled = true;
           btn.style.display='none';
       }

    }, 50);
}

沒有留言:

張貼留言