CRM2011 Disable All Tabs

On Load Event

function onFormLoad() {
    if (Xrm.Page.getAttribute("new_status").getValue() != null) {
        var prstatus = Xrm.Page.getAttribute("new_status").getValue();
        if (prstatus == 5 || prstatus == 6) {
            isformreadonly = true;
            DisableAllControlsInTab(0);
            DisableAllControlsInTab(1);
            DisableAllControlsInTab(2);
            DisableAllControlsInTab(3);
            DisableAllControlsInTab(4);
        }

    }

}




On Save Event to prevent the save the record based on value


function onSave(ExecutionObj)
{
    if (isformreadonly == true) return;
    if (Xrm.Page.getAttribute("new_status").getValue() != null) {
        var prstatus = Xrm.Page.getAttribute("new_status").getValue();
        if (prstatus == 5 || prstatus == 6) {
            alert("It is not allowed to select status as 'Won' or 'Lost'");
            ExecutionObj.getEventArgs().preventDefault();
            return false;
        }
    }
    pricerequesttypeonChange(ExecutionObj);
}

Post a Comment

0 Comments