locked
MSCRM 2011- Activity associated view on account RRS feed

  • Question

  • Hi All,

    I have changed the default setting of 'filter on' to ' All' in open activity associated view in account. But now I also want to change the default in 'Include' to 'This record only' using Javascript. Normally, default value of 'Inclue' is 'Related "Regarding" Records'. Refer to the below image:

    Please help.Thanks in advance.Check 'Include' near 'filter on'

    Tuesday, December 23, 2014 9:52 AM

Answers

  • Use this Script below. Call filterAllActivities function on load.

    function filterAllActivities() {
        document.getElementById("navActivities").onclick = function () {
            Mscrm.Details.loadArea(this, "areaActivities");
    
            document.getElementById("areaActivitiesFrame").onload = function () {
                var entityName = Xrm.Page.data.entity.getEntityName();
                var entity = entityName.charAt(0).toUpperCase() + entityName.substr(1);
                var doc = this.contentWindow.document;
                var filterOn = doc.getElementById("crmGrid_" + entity + "_ActivityPointers_datefilter");
    
                filterOn.value = "All";
    		
    		var FilterRecord = doc.getElementById("crmGrid_" + entity + "_ActivityPointers_ViewControl");
    		FilterRecord.value = "ImmediateRelatedView"; 
    
                var evt = document.createEvent("HTMLEvents");
                evt.initEvent("change", false, true);
                filterOn.dispatchEvent(evt); 
    		FilterRecord.dispatchEvent(evt); 
            };
        };
    } 


    Regards, Saad

    • Marked as answer by Stuti_19 Friday, January 2, 2015 9:19 AM
    • Unmarked as answer by Stuti_19 Friday, January 2, 2015 9:19 AM
    • Marked as answer by Stuti_19 Friday, January 2, 2015 9:19 AM
    Wednesday, December 24, 2014 6:11 AM

All replies

  • Use this Script below. Call filterAllActivities function on load.

    function filterAllActivities() {
        document.getElementById("navActivities").onclick = function () {
            Mscrm.Details.loadArea(this, "areaActivities");
    
            document.getElementById("areaActivitiesFrame").onload = function () {
                var entityName = Xrm.Page.data.entity.getEntityName();
                var entity = entityName.charAt(0).toUpperCase() + entityName.substr(1);
                var doc = this.contentWindow.document;
                var filterOn = doc.getElementById("crmGrid_" + entity + "_ActivityPointers_datefilter");
    
                filterOn.value = "All";
    		
    		var FilterRecord = doc.getElementById("crmGrid_" + entity + "_ActivityPointers_ViewControl");
    		FilterRecord.value = "ImmediateRelatedView"; 
    
                var evt = document.createEvent("HTMLEvents");
                evt.initEvent("change", false, true);
                filterOn.dispatchEvent(evt); 
    		FilterRecord.dispatchEvent(evt); 
            };
        };
    } 


    Regards, Saad

    • Marked as answer by Stuti_19 Friday, January 2, 2015 9:19 AM
    • Unmarked as answer by Stuti_19 Friday, January 2, 2015 9:19 AM
    • Marked as answer by Stuti_19 Friday, January 2, 2015 9:19 AM
    Wednesday, December 24, 2014 6:11 AM
  • Hi Saad,

    Thanks a lot. Its perfect :)

    Friday, January 2, 2015 9:19 AM
  • Hi Mohd,

    I am trying to use this code in other entity (incidents related to an account) and I am trying to filter insted the active incidents, all the incidents related to this account.

    I almost achieve to work because when I click Incidents and it shows you the associated incidents, the view shows you "All" but it didn't really filter by all the records but it continue filter by the active ones.

    I think I am close but I don't know which small part of code I am losing.

    Do you have any idea?

    Best regards and thank you so much,

    Laura G

    Monday, October 31, 2016 12:59 PM