locked
Custom Advance Find view in Iframe in CRM 2011 does not load gird in Firefox AND IE RRS feed

  • Question

  • Hi

    I added a Iframe to my form and in form load event, I load this script :

    var gContext;
    
    function loadIFrame(context) {
    
    	gContext=context.getContext();
        window.fetchActivtities = new FetchViewer("IFRAME_casebysedrialno");
        fetchActivtities.FetchXml = getFetchXml(null,null);
        fetchActivtities.LayoutXml = getLayoutXml();
        fetchActivtities.Entity = "incident";
        fetchActivtities.QueryId = "{B34A5382-F6B7-E311-B5B1-000C2964D6D6}"; // view GUID
        fetchActivtities.RegisterOnTab(2); //IFRAME TAB INDEX
    
    
    }
    
    
    
    function getFetchXml(itemtoSelect,itemValue) {
    
     //  FetchXML Query
        return '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">'+
    				  '<entity name="incident">'+
    					'<attribute name="title" />'+
    					'<attribute name="ticketnumber" />'+
    					'<attribute name="createdon" />'+
    					'<attribute name="incidentid" />'+
    					'<order attribute="title" descending="false" />'+
    					
    				  '</entity>'+
    				'</fetch>';
    
    }
    
    function getLayoutXml() {
    
     // grid layout, you can get easily from Customization.xml file
        return '<grid name="resultset" object="112" jump="title" select="1" preview="1" icon="1">'+
    			  '<row name="result" id="incidentid">'+
    				'<cell name="title" width="150" />'+
    				'<cell name="incidentstagecode" width="100" />'+
    				'<cell name="casetypecode" width="100" />'+
    				'<cell name="prioritycode" width="100" />'+
    				'<cell name="productserialnumber" width="100" />'+
    				'<cell name="severitycode" width="100" />'+
    				'<cell name="statecode" width="100" />'+
    			  '</row>'+
    			'</grid>';
    
    }
    
    function FetchViewer(iframeId) {
        var Instance = this;
        var vDynamicForm;
        var m_iframeTab;
        var m_iframeDoc;
    
        Instance.Entity = "";
        Instance.Iframe = null;
        Instance.FetchXml = "";
        Instance.QueryId = "";
        Instance.LayoutXml = "";
    
        Instance.RegisterOnTab = function (tabIndex) {
            Instance.Iframe = document.getElementById(iframeId);
    
    		
    		
            if (!Instance.Iframe)
                return alert("Iframe " + iframeId + " is undefined");
    
            m_iframeDoc = getIframeDocument();
            var loadingGifHTML = "<table height='100%' width='100%' style='cursor:wait'>";
            loadingGifHTML += "<tr>";
            loadingGifHTML += "<td valign='middle' align='center'>";
            loadingGifHTML += "<img alt='' src='/_imgs/AdvFind/progress.gif'/>";
            loadingGifHTML += "<div/><b>Loading View...</b>";
            loadingGifHTML += "</td></tr></table>";
            m_iframeDoc.body.innerHTML = loadingGifHTML;
    
            Instance.Refresh();
    
        }
    
        function RefreshOnReadyStateChange() {
    
            if (Instance.Iframe.readyState != 'complete')
    		{
    				
    				return;
    		}
    		
    		
                
    
            Instance.Refresh();
        }
    
        Instance.Refresh = function () {
        
            if (!Instance.Iframe)
    		{
    		   
                return alert("Iframe " + iframeId + " is undefined");
    			}
    
            m_iframeDoc = getIframeDocument();
    		
    		
    
            Instance.Iframe.removeEventListener("onreadystatechange", RefreshOnReadyStateChange);
    		
    		
    		
           
            vDynamicForm = m_iframeDoc.createElement("FORM");
    		vDynamicForm.setAttribute("name","vDynamicForm");
    		vDynamicForm.setAttribute("method","post");
    		
    		
    	
    		createTwoAttElem(m_iframeDoc,vDynamicForm,"INPUT","type","hidden","name","FetchXml");
    		createTwoAttElem(m_iframeDoc,vDynamicForm,"INPUT","type","hidden","name","LayoutXml");
    		createTwoAttElem(m_iframeDoc,vDynamicForm,"INPUT","type","hidden","name","EntityName");
    		createTwoAttElem(m_iframeDoc,vDynamicForm,"INPUT","type","hidden","name","DefaultAdvFindViewId");
    		createTwoAttElem(m_iframeDoc,vDynamicForm,"INPUT","type","hidden","name","ViewType");
           
    		
    		
    		
            vDynamicForm.action = gContext.getServerUrl()+("/AdvancedFind/fetchData.aspx");
    		
            vDynamicForm.FetchXml.value = Instance.FetchXml;
            vDynamicForm.LayoutXml.value = Instance.LayoutXml;
            vDynamicForm.EntityName.value = Instance.Entity;
            vDynamicForm.DefaultAdvFindViewId.value = Instance.QueryId;
            vDynamicForm.ViewType.value = 1039;
    		
             
    		
            vDynamicForm.submit();
    
             
            //Instance.Iframe.attachEvent("onreadystatechange", OnViewReady);
    		
    		Instance.Iframe.addEventListener("onreadystatechange", OnViewReady);
    		
    		
        }
    
        function OnViewReady() {
    	
    	      
            if (Instance.Iframe.readyState != 'complete') return;
    
            Instance.Iframe.style.border = 0;
            Instance.Iframe.removeEventListener("onreadystatechange", OnViewReady);
            m_iframeDoc = getIframeDocument();
            m_iframeDoc.body.scroll = "no";
            m_iframeDoc.body.style.padding = "0px";
        }
    
        function getIframeDocument() {
    		myFrame = Instance.Iframe;
    
            myWindow = myFrame.contentWindow;
    
            myDoc = myWindow.document;
            return myDoc;
        }
    
    }
    
    function createTwoAttElem(doc,eletoAppend,elemname,att1,att1val,att2,att2val)
    {
    
    	var newelem = doc.createElement(elemname);
    	newelem.setAttribute(att1,att1val);
    	newelem.setAttribute(att2,att2val);
    	
    	eletoAppend.appendChild(newelem);
    
    }

    it works prefectly in Chrome but in IE and Firefox, it only shows "Loading View ...". I inspected network requestes in all three browsers, and saw that in Chrome there is a post request to "fetchData.aspx" but there is not such request in firefox or IE.

    P.S: I already read this question

    Sunday, March 30, 2014 4:14 PM

All replies

  • Have you narrowed down where it actually stops yet?
    Monday, March 31, 2014 4:15 AM
  • ُSorry But I did not get your question.

    But I have made breakpoints in code an did not see any error there. I used console.log(...) to trace the program, and saw that it passes :

      vDynamicForm.submit();

    But there is not any post request to "fetchData.aspx"

    Monday, March 31, 2014 8:14 AM
  • Instead of creating the form using document.Createelement and ... I created the form by string and put it into Innerhtml of Iframe and it worked 

    
    
    var innerform='<form name="vDynamicForm" method="post" action="http://win-c54fib79nbi:5555/test2/AdvancedFind/fetchData.aspx">'+
    
    			'<input type="hidden" name="FetchXml" value="'+Instance.FetchXml+'">'+
    			'<input type="hidden" name="LayoutXml" value="'+Instance.LayoutXml+'">'+
    			'<input type="hidden" name="EntityName" value='+Instance.Entity+'>'+
    			'<input type="hidden" name="DefaultAdvFindViewId" value='+Instance.QueryId+'>'+
    			'<input type="hidden" name="ViewType" value="1039">'+
    
    			'</form>';
    			
    		  m_iframeDoc.body.innerHTML = innerform;
    
    		m_iframeDoc.vDynamicForm.submit();

    Tuesday, April 1, 2014 8:46 AM