locked
CRM 2011 adding reporting server report to navigation bar with custom parameter. RRS feed

  • Question

  • Greetings,

    I am having a problem with getting reports to work with CRM 2011, I think it was in RU11 or RU12 and the latest browsers that they started to work funny or not at all.

    The setup is like this.

    • Report server report not CRM report.
    • Viewable through a navigation link with external url set.
    • Accountnumber is sent in as parameter with form javascript that runs onload and updates the external url.

    Here is the code I use to update the url for the report.

    function form_OnLoad()
    {  
      var items = Xrm.Page.ui.navigation.items.get();
    
      for (var i in items) 
      {
       var item = items[i];
       var itemLabel = item.getLabel();
    
       if(itemLabel == "Link name")
       {
         var areaId1 = item.getId();
         var navVal1 = document.getElementById(areaId1); 
        
        if (navVal1 != null && navVal1 != undefined)
        { 
          var u2 = encodeURI("Report URL"+ crmForm.all.accountnumber.value); 
    
          navVal1.onclick = function () 
          {
           loadIsvArea(Mscrm.CrmUri.create(u2), false)
           var navIframeObject = document.getElementById(areaId1+"AreaFrame"); 
           if(navIframeObject != null)
           {
            navIframeObject.src = u2;
           }
          };
        }
       }
      }
    }

    I usually get an error when I click the link

    <CrmScriptErrorReport>
      <ReportVersion>1.0</ReportVersion>
      <ScriptErrorDetails>
       <Message>Unable to get value of the property 'target': object is null or undefined</Message>
       <Line>1</Line>
       <URL>/_static/_common/scripts/details.js?ver=-1616214599</URL>
       <PageURL>/userdefined/edit.aspx?_gridType=1&etc=1&id=%7b55A3B8A6-0680-DD11-B551-00127994389A%7d&pagemode=iframe&preloadcache=0000&rskey=0000</PageURL>
       <Function>anonymous(selectedNavLink,url,passParams,domEvent){if(passParams)url=addIsvParameters(url);var$v_0=domEvent.target;while(!IsNull($v_0)&&$v_0.tagName!=="A")$v_0=$v_0.parentNode;returnMscrm.Details.loadArea(selectedNavLink,$v_0.id+"Area","",url,true,passPar</Function>
       <CallStack>
        <Function>anonymous(selectedNavLink,url,passParams,domEvent){if(passParams)url=addIsvParameters(url);var$v_0=domEvent.target;while(!IsNull($v_0)&&$v_0.tagName!=="A")$v_0=$v_0.parentNode;returnMscrm.Details.loadArea(selectedNavLink,$v_0.id+"Area","",url,true,passParams)}</Function>
       </CallStack>
      </ScriptErrorDetails>
    </CrmScriptErrorReport>

    Any suggestions would be greatly appreciated, be it a fix for this or a proper way to do this.

    Best regards,
    Halldór


    Halldór Jóhannsson



    Monday, June 16, 2014 10:39 AM

Answers

  • I managed to fix this issue with a new approach, so here is the information if anyone else is in need of fixing something like this.

    Create a web resource instead of using Navigation link with URL and then javascript to add the parameter to the url.

    1. Create Navigation item with a web resource.
    2. Create the web resource as a Web Page (HTML)
    3. Modify the script below as needed and then add to the webpage.

    Following example is for the account form using the accountnumber field as parameter for the report.

    <html>
     <head>
      <meta charset="utf-8">
      <script type="text/javascript">
    function GetAccountNumber() {
    return window.parent.Xrm.Page.data.entity.attributes.get("accountnumber").getValue();
    }
      </script>
     </head>
    <body onload="window.location = 'http://reportserver/ReportServer?/ReportPathAndName&amp;rs:Command=Render&amp;rc:toolbar=false&amp;parameter1=' + GetAccountNumber();">
    </body>
    </html>


    Halldór Jóhannsson

    Wednesday, June 25, 2014 11:16 AM

All replies

  • Anyone, any ideas?

    Halldór Jóhannsson

    Wednesday, June 18, 2014 9:37 AM
  • I managed to fix this issue with a new approach, so here is the information if anyone else is in need of fixing something like this.

    Create a web resource instead of using Navigation link with URL and then javascript to add the parameter to the url.

    1. Create Navigation item with a web resource.
    2. Create the web resource as a Web Page (HTML)
    3. Modify the script below as needed and then add to the webpage.

    Following example is for the account form using the accountnumber field as parameter for the report.

    <html>
     <head>
      <meta charset="utf-8">
      <script type="text/javascript">
    function GetAccountNumber() {
    return window.parent.Xrm.Page.data.entity.attributes.get("accountnumber").getValue();
    }
      </script>
     </head>
    <body onload="window.location = 'http://reportserver/ReportServer?/ReportPathAndName&amp;rs:Command=Render&amp;rc:toolbar=false&amp;parameter1=' + GetAccountNumber();">
    </body>
    </html>


    Halldór Jóhannsson

    Wednesday, June 25, 2014 11:16 AM