title: How to execute Report in Dynamics CRM 2013 to generate PDF in Online mode and offline
body: <p>Could some one help me out !!!
  I have got a custom button in the Entity Quote to generate a PDFs file from a report . 
  It work perfectly if the CRM is on-line , but once I switch in to outlook as offline mode 
  it is not working . Because it is not getting a Session id and Control Id</p>
  
  <pre><code>var pth="";
          if(IsOnline)
          {
          pth= Xrm.Page.context.getServerUrl() + "/CRMReports/rsviewer/reportviewer.aspx";
          }
          else
          {
          pth= " http://localhost:2525/crmreports/viewer/viewer.aspx";
          }
          var retrieveEntityReq = new XMLHttpRequest();
          var Id = Xrm.Page.data.entity.getId();
          var quotationGUID = Id.replace('{', ""); //set this to selected quotation GUID
          quotationGUID = quotationGUID.replace('}', "");
          var reportName = "Quote"; //set this to the report you are trying to download
          var reportID = "6A39D18F-2EC6-E344-8986-F49D6765A723"; //set this to the guid of the report you are trying to download
          var rptPathString = ""; //set this to the CRMF_Filtered parameter
          var strParameterXML = "&lt;fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'&gt;&lt;entity name='quote'&gt;&lt;all-attributes /&gt;&lt;filter type='and'&gt;&lt;condition attribute='quoteid' operator='eq' uitype='quote' value='" + quotationGUID + "' /&gt; &lt;/filter&gt;&lt;/entity&gt;&lt;/fetch&gt;";
          retrieveEntityReq.open("POST", pth, false);
          retrieveEntityReq.setRequestHeader("Accept", "*/*");
          retrieveEntityReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
          rptPathString = "id=%7B" + reportID + "%7D&amp;uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&amp;iscustomreport=true&amp;reportnameonsrs=&amp;reportName=" +
          reportName + "&amp;isScheduledReport=false&amp;p:CRMAF_Filteredquote=" + strParameterXML;
          //remove the part starting from &amp;p:salesorderid if your report has no parameters
          retrieveEntityReq.send(rptPathString);
          var x = retrieveEntityReq.responseText.indexOf("ReportSession=");
          var ret = new Array();
          ret[0] = retrieveEntityReq.responseText.substr(x + 14, retrieveEntityReq.responseText.indexOf("&amp;", x) - x - 14); //the session id
          x = retrieveEntityReq.responseText.indexOf("ControlID=");
          ret[1] = retrieveEntityReq.responseText.substr(x + 10, retrieveEntityReq.responseText.indexOf("&amp;", x) - x - 10); //the control id
  
          return ret;
  </code></pre>