Tuesday, May 20, 2014

Refreshing a Dashboard in Partner Community Portal

Salesforce has introduced dashboards in Partner Communities. However, Partner users do not have the ability to refresh any dashboard they have access to with the exception of the top row of any dashboard located on their Home page.  The List of “Report and Dashboard Limitations for Partner Community Users” can be found here. 

For a company who has a lot of Partner users, need the ability for these users to refresh a dynamic dashboard. Many customers implemented a solution to create individual dashboards for each partner, but dashboard doesn’t refresh automatically. A dashboard refresh is very critical as it is embarrassing to put a dashboard in front of partner users with data that is up to a month old. This defeats the purpose of them using dashboards and the Communities.

Bob Buzzard found a great solution to refresh a dashboard in Partner Communities. Here is the link to his solution “Automatic Dashboard Refresh”. Many thanks to Bob…

I have further worked on Bob’s clue and developed a simple solution similar to what Salesforce has offered to its standard users. I have used Simple XMLHttpRequest inside a Visualforce page to refresh a dashboard. This doesn’t require any controller, hence no need to write any test class. J


Step 1: Create a new Visualforce page with following code.
1:  <apex:page showHeader="false" sidebar="false" standardStylesheets="false">  
2:  <script type="text/javascript">  
3:  function refresh_win()  
4:  {  
5:       xmlhttp=new XMLHttpRequest();  
6:       xmlhttp.open("POST","https://{YourSiteName}.force.com/{YourPage}/dash/dashboardRefresh.apexp?id={YourDashboardID}",false);  
7:       xmlhttp.send();  
8:       alert('Refreshing Dashboard');  
9:       setTimeout('self.close();',2000);  
10:      setTimeout('parent.location.reload();',1000);  
11:  }  
12:  </script>  
13:  <form>  
14:  <input type="button" value="Refresh" onclick="refresh_win()"/>  
15:  </form>  
16:  </apex:page>  

Step 2: Adding this Visualforce page in a Dashboard

Go to Partner Dashboard. Click Edit. Add a new Visualforce component and this new Visualforce page. Set desired height and type relevant message. And you are Done…!