0

Is it possible to display the reports and dashboards in the visual force page? If yes, can anybody provide me with some reference.

1

There are multiple ways to do this.

This is the easiest way probably.

analytics:reportChart

You can specify the report ID and it pretty much takes care of the rest. It also comes with a refresh button.

<analytics:reportChart reportId="00O90000009VK2d"/>

UPDATE:

To fetch the private reports shown on the private dashboard, you need to do a few query.

  1. Get the Dashboard ID using UserInfo.getUserId()

    SELECT Id FROM Dashboard where FolderId = :UserInfo.getUserId() LIMIT 1

  2. Once you have the dashboardId, fetch its report components using another query:

    SELECT CustomReportId,DashboardId FROM DashboardComponent where DashboardId = :dashboardId

OR

You could fire both the query in a single SOQL:

SELECT CustomReportId,DashboardId FROM DashboardComponent where DashboardId IN (select ID  FROM Dashboard where FolderId = :UserInfo.getUserId())

So all the CustomReportId returned in the last query will be your list of report IDs to be passed on to analytics:reportChart.

  • 1
    reportId is hardcoded. i need whichever user logged in get their personal dashboard how we can get from userinfo.getuserId(); – cloudZigZag Apr 18 '17 at 5:42
  • You should have mentioned that in the question itself. Anyway, updated my answer. – Santanu Halder Apr 18 '17 at 6:06
  • Did it helped you? if yes, please close the thread by accepting the answer, if not, let me know if you have questions. – Santanu Halder Apr 19 '17 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.