Get project name or id for dashboard in document.ready()

I have an issue where users have bookmarked dashboards that are no longer being updated.

For example, months ago a user logs in and goes to their default view. They set a bookmark which has /Dashboard/{DashboardIDGuid}. We now deployed a new version in a separate project. We still have the old project up for reference, but we do not want users to go to any dashboards in the old project. The issue is when they click their bookmark, they go to the old dashboard.

I have a javascript override for document.ready(). I would like to do the following.

  1. Determine which dashboard they have requested. Don’t know if there is anything in the javascript library to get this or I have to parse the url. I’m cool either way.
  2. Find out the project id or name that the requested dashboard is in.
  3. If the project is the old project, then redirect them to their default view.

OR

Override the logon submit event to redirect them to their default view regardless of the ReturnUrl parameter in the url.

Thanks
Matt

Hi Matt,

You can use the Dundas BI baseViewService to get all the required details about the loaded/requested view.
The following script uses the “baseViewService” to get the ID as well as the name of the requested dashboard (or any view) as well as the id of the project to which the requested dashboard/view belongs to:

dundas.context.ready(function () {
	window.dundas.context.ready(function () {
		if (window.dundas.context.currentPage == dundas.Pages.DASHBOARD) {
			var dashboardID = window.dundas.context.baseViewService.currentView.id;
			var dashboardName = window.dundas.context.baseViewService.currentView.name;
			var parentProjectID = window.dundas.context.baseViewService.currentView.control.projectId;
			console.log("Dashbaord ID - "+dashboardID+" Name - "+dashboardName+" ProjectID - "+parentProjectID);
		}
	})
})

You can add this script to your ready action within your JavaScript override file within the Scripts\Override folder of your Dundas BI instance. You can then use these details to redirect the user as required. We have a great sample in our Script Library that you can refer to, to set up the required navigation:
https://www.dundas.com/Support/developer/script-library/services/view-service/navigating-to-pages