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

Using Apex to refresh dashboards on a nightly basis

Hi guys,


I'm trying to figure a way to get our dashboards to auto-refresh each night. Now, given we're running over 100 dashboards, using the Schedule Refresh option isn't an option.


Reading up on all of this, I can see there are a couple of javascript ways to trick the browser to issue a refresh on a given dashboard. A little hacky, but seems to be the only way so far I can find.


Now I was thinking of using a Http request from Apex to call the "refresh" Url, and hoping Salesforce would issue the refresh (and not be overly worried that the request is not really a browser). I'll assume I need to include cookies and headers in my request with Session IDs and other authentication pieces before this can work. Has anyone used the Http and HttpRequest objects/methods in Apex to call SFDC itself (and managed to authenticate?)


Second concern is there is no simple way to query the Dashboards for a list of Dashboard Ids. Sadly, it looks like the only way around this is to define a custom Object, and steal the list of Dashboard Ids out of the Html source straight from Dashboard tab. Has anyone else figured a way to get/query dashboards in Apex?


I might try and build a prototype call in apex, and see if I can get the Http request to hit Salesforce and authenticate... but would dearly appreciate some advice if other devs have tried their hand at this before?


If successful, glad to share code/walk-through.



Vaughan Crole



Why do you have so many dashboards you need to refresh?   Do you have 100's of users and you are creating dashboards for each?


Hopefully there is something on the horizon that will keep you from having to pursue an unsupported hack that is prone to failure do to any number of reasons and may even become explicitly blocked.


any sucess wiht that? woudl love to see your code

my s control broke with new release