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

getParameter, VisualForce and Dashboards

Hi all, I've been programming in Apex/VisualForce for the past couple of weeks, just getting used to everything, and I've hit a bit of a roadblock.

I'm trying to generate a Google Chart from company statistics that we track and aggregate into reports and dashboards. On the particular dashboard is a very simple VisualForce page.

I'm putting some code in here, but the server continually times out when I hit Preview so I apologize if it doesn't look too good below.

I have this visualforce page:

<apex:page controller="MyStatsController" action="{!MyStatsController}">

<apex:image url="{!ReturnedURLFromController}"></apex:image>


Next is my controller:

public class MyStatsController {

   String ReturnedURLFromController;

   List data;

   public void MyStatsController()


      String cid = System.currentPageReference().getParameters().get('cid');

      Data = [Select ... where company_id =: cid ];


      ReturnedURLFromController = GenerateChartURL();


   public string GenerateChartURL(){

      //Works on data to make the google chart url

      return chart_url;



This is my problem line:

String cid = System.currentPageReference().getParameters().get('cid');

When I open the Dashboard page from a custom link, the url resembles this:


But no matter what I do, my controller is finding cid as null. I have a check after cid gets assigned and if its still NULL after the getParameter().get()  call, it loads bogus data and changes the chart's title to a warning message, and this is what I get everytime.


If anyone can point me in the right direction here, I would really appreciate it.


Try with this instead



While talking over this issue, we figured out that the Dashboards load VF pages as iframes, which meant that the VF page didn't have access to the Dashboard's URL. It doesn't seem that there is a great way around this, but I was able to make a quick Javascript implementation on the VF page that grabs the Dashboard's URL with window.parent.document.location.href, and am parsing out the query parameter with a simple string function (I'll post it tomorrow if anyone is interested). I'm still struggling with how to get THAT value over to APEX, <apex:param> hasn't helped since it has to be within a button, link, etc. But I'll look at using apexPages.etc(...) again, it didn't seem to be grabbing it earlier but I might have missed something.

Hi Suma,

I have a similar issue if not fully alien.

I have visualforce page showing report data in a page block table. I want to show this page as dashboard component. Is there any way to achieve this easily? I have heard that dashboard component wont get created if you use a Standard Controller, but if you use Controller class or call/refer a page having StandardSetController Class from the concerned vf page, you may have the component available.

Could you please advise on this.