Archive

Posts Tagged ‘linkedin crm’

CRM Form Collapsible Sections

December 8, 2011 Leave a comment

//Add collapsible functionality to sections.
/*********************************************************************/

function attachCollapsableToSections() {
    var sections = getElementsByCondition(function(elm)
    { if (elm.className.indexOf("ms-crm-Form-Section") != -1) return true; }, null);
    for (var i = 0; i < sections.length; i++) {
        sections[i].innerHTML = ‘<img  alt="Expanded, click to collapse" src="/_imgs/navup.gif" style="cursor:hand;"/>’ + sections[i].innerHTML; sections[i].childNodes[0].attachEvent(‘onclick’, toggleVisibility);
    }
}
function attachCollapsableToSections() {
    var sections = getElementsByCondition(function (elm) { if (elm.className.indexOf("ms-crm-Form-Section") != -1) return true; }, null);

    for (var i = 0; i < sections.length; i++) {

        sections[i].innerHTML = ‘<img  alt="Expanded, click to collapse" src="/_imgs/navup.gif" style="cursor:hand;"/>’ + sections[i].innerHTML;
        sections[i].childNodes[0].attachEvent(‘onclick’, toggleVisibility);
    }

}

function toggleVisibility(e) {
    var sectionContainer = e.srcElement.parentNode.parentNode.parentNode;

    var elements = getElementsByCondition(function (elm) { if (elm.vAlign == "top") return true; }, sectionContainer);

    for (var i = 0; i < elements.length; i++) {
        if (elements[i].style.display == "none") {
            elements[i].style.display = "";           
            e.srcElement.src = e.srcElement.src.replace("navdown", "navup");
        }
        else {
            elements[i].style.display = "none";           
            e.srcElement.src = e.srcElement.src.replace("navup", "navdown");
        }
    }
}

function getElementsByCondition(condition, container) {
    container = container || document;
    var all = container.all || container.getElementsByTagName(‘*’);
    var arr = [];
    for (var k = 0; k < all.length; k++) {
        var elm = all[k];
        if (condition(elm, k))
            arr[arr.length] = elm;
    }
    return arr;
}
/*********************************************************************/

Categories: CRM Tags:

Disable an entire CRM Form

July 27, 2011 Leave a comment

Used to disable an entire form after a certain status has occurred:

for (var index = 0; index < crmForm.all.length; index++)
{
    if(crmForm.all[index].Disabled != null)
    {
        crmForm.all[index].Disabled = true;
    }
}

Categories: Coding, CRM Tags: