Wednesday, November 9, 2011

CRM 2011 - how to set 'Filter On' filter to value 'All' for Activities

Add this Script Library and  add ChangeFilterLoad to Form Load

function ChangeFilterLoad() {
    if (document.getElementById('navActivities') != null) {
        document.getElementById('navActivities').onclick = function () {
            loadArea('areaActivities');
            ChangeFilter();

        }
    }


}


function ChangeFilter() {
    //Activity scheduledend options
    var ActivityOptions =
{
    All: "All",
    Overdue: "Overdue",
    Today: "Today",
    Tomorrow: "Tomorrow",
    Next7Days: "NextXDays;7",
    Next30Days: "NextXDays;30",
    Next90Days: "NextXDays;90",
    Next6Months: "NextXMonths;6"
}

    //Activity History actualend options
    var HistoryOptions =
{
    All: "All",
    Today: "Today",
    Yesterday: "Yesterday",
    Last7Days: "LastXDays;7",
    Last30Days: "LastXDays;30",
    Last90Days: "LastXDays;90",
    Last6Months: "LastXMonths;6",
    Last12Months: "LastXMonths;12"
}




    sArea = "areaActivities";
    //create the iframe object
    var iframe = document.getElementById(sArea + "Frame");
iframe.onreadystatechange = function()
{
if( iframe.readyState == "complete")
{
    var picklist, option;
    //reference to the iframe document
    var iframeDoc = iframe.contentWindow.document;
    switch (sArea) {
        case "areaActivities":
            picklist = (iframeDoc.getElementById('crmGrid_Contact_ActivityPointers_scheduledend'));//This is the drop daown id attact to contact form
            /* change to suit your needs */
            option = ActivityOptions.All;
            break;
        default: return;
    }
    picklist.value = option;
    picklist.FireOnChange();
}
}
}

No comments:

Post a Comment