Search code examples
javascriptiframedynamics-crm-2015webresource

Unable to get property 'setSrc' of undefined or null reference: Cant figure out this error.


I have upgraded from CRM 2011 to CRM 2015 Online and when I open up a "Contact:Information" record I get an error saying: Unable to get property 'setSrc' of undefined or null reference at fiframhistory(name of web resource) This is for an Iframe that I am using to display records related to the GUID of a Contact record. Here is the code:

function fIframeHistory() {
    var vCustomerID = Xrm.Page.data.entity.getId();
    if (vCustomerID == null) {
        Xrm.Page.getControl("IFRAME_ACTIVITY_HISTORY").setVisible(false);
        Xrm.Page.getControl("IFRAME_ACTIVITIES_OPEN").setVisible(false);
    }
    else {
        var vURL = "http://aac.phoenixcoyotes.com/coyoteshockeyllc/userdefined/areas.aspx?oId=" + vCustomerID + "&oType=2&pagemode=iframe&security=852023&tabSet=areaActivityHistory";
 //var vURL = "http://coyotescrm/coyoteshockeyllc/userdefined/areas.aspx?oId=" + vCustomerID + "&oType=2&pagemode=iframe&security=852023&tabSet=areaActivityHistory";

        Xrm.Page.ui.controls.get("IFRAME_ACTIVITY_HISTORY").setSrc(vURL);
        var vURLB = "http://aac.phoenixcoyotes.com/coyoteshockeyllc/userdefined/areas.aspx?oId=" + vCustomerID + "&oType=2&pagemode=iframe&security=852023&tabSet=areaActivities";
 //var vURLB = "http://coyotescrm/coyoteshockeyllc/userdefined/areas.aspx?oId=" + vCustomerID + "&oType=2&pagemode=iframe&security=852023&tabSet=areaActivities";

        Xrm.Page.ui.controls.get("IFRAME_ACTIVITIES_OPEN").setSrc(vURLB);
    }
};

Solution

  • Try using:

    Xrm.Page.getControl("IFRAME_ACTIVITY_HISTORY").setSrc(vURL);

    https://msdn.microsoft.com/en-us/library/51828fe3-f6ff-4f97-80ed-b06b3a354955#BKMK_setSrc