1


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.

2
  • Do you already know it?
    – felipe.zkn
    Nov 25, 2016 at 16:13
  • I don't know what you are asking Felipe. I am asking for suggestion on opening the reports in a new tab using <analytics:reportChart> tag. What is not clear?
    – goabhigo
    Jan 20, 2017 at 9:33

1 Answer 1

1

I also experienced this issue for anyone navigating to this page after countless hours of scouring the internet. I am happy to share a solution that worked for me.

First, you will need to create two reports to satisfy this requirement. One is used for the embedded report (Page report) and another to use for renavigation of the View Report onClick event to the (URL report).

Notes:

In addition, the "Available for Lightning Experience, Experience Builder sites, and the mobile app" checkbox should be checked on the Visualforce page if you intend to embed it within a record page.

Visualforce Page:

<apex:page standardController="Case" sidebar="false">
    <!-- The JavaScript below builds the URL for the filtered URL report. The report filters on Cases associated with the Account ID listed on the Case 
    detail page.-->    
    <script type="text/javascript">
        function changeURL()
        {
            var url = '/lightning/r/Report/' + "{!$Setup.Custom_Setting__c.URL_Report_ID__c}" + '/view?fv0={!Case.AccountId}'; 
            window.parent.location.replace(url);
        }
    </script>
    
    <div onClick="changeURL()">
        <!--The div below disables the View Report link navigation which natively directs users to the Page specific report and opens the URL specific report.-->
        <div style="pointer-events: none">
            <!--The analytics report chart displays a report pie chart of Cases by reason. The report filters on Cases associated with the Account ID listed on the Case detail page.-->    
            <analytics:reportChart reportId="{!$Setup.Custom_Setting__c.Page_Report_ID__c}" 
                hideonerror="false" 
                filter="{column:'ACCOUNT_ID', operator:'equals', value:'{!Case.AccountId}'}" 
                size="tiny" 
                cacheResults="false"
                showRefreshButton="false"/>
        </div>
    </div>
</apex:page>
6
  • In addition, the "Available for Lightning Experience, Experience Builder sites, and the mobile app" checkbox should be checked on the Visualforce page if you intend to embed it within a record page.
    – Dominique
    May 9, 2022 at 15:38
  • Welcome to Salesforce Stack Exchange (SFSE)! Thank you for the detailed contribution. A couple of points: Firstly, it is considered poor etiquette on SFSE to prompt for having your answer marked as best. Secondly, rather than adding additional important info as a comment where it could easily be overlooked, please edit your answer to add the good info from your comment. At the bottom left of every post you can see "Share Edit Follow Flag"; click "Edit".
    – Moonpie
    May 9, 2022 at 15:53
  • @Moonpie - I did not prompt to have my answer marked the best in any way and understand the importance of leaving that to the original contributor. Thank you for your contributions. I will update my suggested solution with the comment I provided.
    – Dominique
    Oct 25, 2022 at 15:38
  • (1/2) We have all - here or somewhere else (virtual or in real life) - ignorantly (I mean that in the proper way of lacking the knowledge, or being unaware or uninformed - I do NOT mean lacking the intellect) broken a community's etiquette or norms, especially when we were new. Hence why the tone & content of my original comment was to educate, not to scold, belittle or be demeaning. Had you simply indicated your lack of awareness of our etiquette in your recent comment, or just not said anything else, no one would have thought any more on it & I would not be typing these follow-up comments.
    – Moonpie
    Oct 25, 2022 at 17:05
  • (2/2) However, I am commenting because I do not appreciate blatant dishonesty. If you click "edited [whatever day/time] ago" at the bottom of your post, you will see the history of the post and all edits. At the bottom is the #1 revision - that is the original posting. The last line reads, "P.S. I hope this helps someone. Please mark as the best answer if this helped you." That sounds to me exactly like "prompt[ing] to have [your] answer marked the best."
    – Moonpie
    Oct 25, 2022 at 17:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .