How to Publish or Save a Dashboard via JavaScript API method?
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:
|
||||||||||||
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.