function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
goabhigogoabhigo 

Opening report in new tab/window in Analytics reportChart

Hi all,

I have created a VF page with couple of reports. These reports are filtered, based on the selection available. For now assume the filter is just the Owner Name. All works well - I have used to show the report chart and have used cacheResults="false" to ensure the reports get refreshed on load. 

Now coming to the issue I am facing - when the user clicks on the report chart the report opens in existing window/tab. I want it to be opened in new tab/window. I have tried using onclick() and < a >tag, but no luck. 

Can anybody suggest if there is a way to do this? 

Here is the very sample code - without filters - just a simple page with report chart.
<apex:page>
     <a href='/00ON0000000LRNi' target='_blank'>
        <analytics:reportChart reportId="00ON0000000LRNi"></analytics:reportChart>
     </a>
</apex:page>

Interestingly the block becomes clickable and opens in new tab. Please note that including the filters in doesn't work for some reports. So I guess this is not the solution. Also note that there is no attributes available in reportChart to open this in new tab.

Please suggest.
swati_sehrawatswati_sehrawat
<apex:page>
<script type="text/javascript">
    function Test(){
        var url = 'https://ap1.salesforce.com/ReportId';
        window.parent.location.replace(url);
    }
</script>
<apex:outputLink onclick="Test();">
    <analytics:reportChart reportId="ReportId"></analytics:reportChart>
</apex:outputLink>
</apex:page>

Try something like this and let me know if it worked.
swati_sehrawatswati_sehrawat
Replace reportId with your report ID
goabhigogoabhigo
Thanks Swati. I have tried this, but the report opens in the existing window/tab itself. This poast, related to onclick() is the one which is commonly available in Discussion Forum and StackExchange. But it doesn't work. Please try it for yourself.
swati_sehrawatswati_sehrawat
Hello,

Am sorry for the miss but can you try this one.

<apex:page >
<script type="text/javascript">
    function Test(){
        var url = 'https://ap1.salesforce.com/00O90000009B17M';
        window.open(url,'_blank');
        //window.parent.location.replace(url);
    }
</script>
<apex:outputLink onclick="Test();">
    <analytics:reportChart reportId="00O90000009B17M"></analytics:reportChart>
</apex:outputLink>
</apex:page>

I have tried this in my Org and on click report opens in new tab.
goabhigogoabhigo
Thanks. But the issues with this are:
  1. The report opens in both the tabs
  2. Mainly, the chart filters needs to be recreated or rather passed as parameter. Report filters do not work with url parameters in custom fields.
When the filters are already fetched and applied on report, the simple solution should be onlcik of the chart it opens in the new tab. Sadly Salesforce doesn't provide this. Probably after introducing this tag they were occupied in Analytics Cloud/Wave rather than imprving this tag :(

--
Abhi
Kellan ScheiberKellan Scheiber
I have run into the same issue and have not found a way to add to analytics:reportChart. What I did was add an <a> tag with the link to the report about the chart and kept the chart, end users can then click on link to open in new window.

<a href="https://sogetikellanscheiber-dev-ed.my.salesforce.com/00O610000045q1f" target="_blank" cacheResults="false">Open Reservation Report</a> 
            
           <apex:outputPanel >
              <analytics:reportChart reportId="00O610000045q1f" showRefreshButton="true" size="huge" cacheResults="false"/>
           </apex:outputPanel>  
            
        </apex:pageBlock>
Mark MogridgeMark Mogridge
Great job Swati! Works a treat!