Articles in this section
Category / Section

How to Publish or Save a Dashboard via JavaScript API method?

Published:

In some cases, you may want to call the publish or save function of a dashboard via an API call instead of using the embedded designer’s generic button. This article will guide you through the process of implementing this functionality.

Creating a New Dashboard Category

To create a new category for your dashboard, you can use the createDashboardCategory() method. This method will create a new category on the server.

var instance = BoldBI.getInstance("container"); //container -> embed container id
instance.createDashboardCategory(categoryName, categoryDescription, callBackFnc, containerId);

function callBackFnc(args) {
   // The parameter args contains the status whether category is added or not.
}
Parameter Type Description
categoryName string Need to set the name to create a new category in the server.
categoryDescription string Need to set the description of new category.
callBackFnc string This method will act as call back function ,it will return the status of whether category is added or not.
containerId string Need to set embed container id.

Retrieving Existing Dashboard Categories

To retrieve existing dashboard categories from the Bold BI server, you can use the getDashboardCategories() method.

var instance = BoldBI.getInstance("container"); //container -> embed container id
instance.getDashboardCategories(callBackFnc, containerId);

function callBackFnc(args) {
   // The args parameter contains the list of categories available in the server as an array, which contains CategoryId and CategoryName
}
Parameter Type Description
callBackFnc string This method will act as call back function ,it will get the category list from the server.
containerId string Need to set the embed container id.

Publishing or Saving a Dashboard

To publish or save a dashboard, you can use the saveDashboard() method. This method can be used for the following scenarios:

  • Publish or Save a new dashboard
  • Publish or Save an existing dashboard
  • PublishAs or SaveAs an existing dashboard

The saveDashboard() method accepts an object with the following parameters:

Parameter Type Description
publishModel object This object contains the following Parameters:
category Set the name of the category in the dashboard will be published.
categoryId Set the unique id of category in the dashboard will be published, the category Id taken from getDashboardCategories().
description Set the description in the dashboard will be published.
id Save the new dashboard - Dashboard Id value can be empty here.
Save the existing dashboard - Dashboard Id value should be valid.
SaveAs the existing dashboard - Dashboard Id value can be empty here.
isPublic Need to set the publish dashboard as public or not.
name Set the Name of the dashboard in the dashboard will be published.
containerId string Set the embed container id.

Example: Save a New Dashboard

var instance = BoldBI.getInstance("container"); //container -> embed container id
// For Save the New Dashboard case, Dashboard Id value is not needed
var publishModel = {category: "Sales", categoryId: "e6ed2f36-7205-423e-81e0-38a8ceb8e68c", description: "Published Using API", isPublic: false, name: "Publish API_01"}
instance.saveDashboard(publishModel, containerId);

Example: Save an Existing Dashboard

var instance = BoldBI.getInstance("container"); //container -> embed container id
// For Save the Existing Dashboard case, Dashboard Id value is needed
var publishModel = {category: "Sales", categoryId: "e6ed2f36-7205-423e-81e0-38a8ceb8e68c", description: "Published Using API", id: '451e17e5-e59f-4090-84a2-cf5537876e59', isPublic: false, name: "Publish API_01"}
instance.saveDashboard(publishModel, containerId);

Example: SaveAs an Existing Dashboard

var instance = BoldBI.getInstance("container"); //container -> embed container id
// For SaveAs the existing Dashboard case, Dashboard Id value is not needed
var publishModel = {category: "Sales", categoryId: "e6ed2f36-7205-423e-81e0-38a8ceb8e68c", description: "Published Using API", isPublic: false, name: "Publish API_01"}
instance.saveDashboard(publishModel, containerId);

Note: You can customize the saveDashboard() method in the dashboard designer using a web application. For more details, please refer to the Bold BI documentation.

Additional References

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
SM
Written by Soundarya Mani Meharan
Updated:
Comments (0)
Please  to leave a comment
Access denied
Access denied