Restoring dashboards default settings automatically

In this post you can learn how to automatically 'Restore Dashboard' on each page refresh or opening, this setting will always restore the dashboards initial published state for your viewers and designers.
This can be used for cases where you would like to keep things simple for your dashboard users, removing previous selections and filter changes. This can also help some of your less technical dashboard users to stay organized and assure they are receiving the correct information when loading the report.
In order to do so, please paste the following script into the dashboards script:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
dashboard.on('initialized', function(se, ev){ 
if (localStorage.getItem('toRefreshPage') == 'true') 
{ 
if (prism.user.roleName != 'super' && window.navigator.userAgent.indexOf('phantom') == -1) 
{ 
var dashid = '55e45211ecb61bf493000131', 
$state = prism.$injector.get('$state'); 

localStorage.setItem('toRefreshPage', "false"); 

prism.activeDashboard.$dashboard.restoreSharedDashboard(dashid).then(function(dash){ 
$state.go('layout.shell.dashboard', { 
dashboardid: dashid, 
ref: $$guid_fast(4) 
}); 
}); 
} 
} 
else 
{ 
localStorage.setItem('toRefreshPage', 'true'); 
} 

});
Note: The Dashboard ID '55e45211ecb61bf493000131' is just an example, please change it to the relevant dashboard ID you would like to use this script with.