Skip to content

Bookmarks

Amit Shuster edited this page Nov 17, 2020 · 17 revisions

By using bookmarks in Power BI, you can capture the current configured view of a report page, including filtering and the state of visuals.

Note: For personal bookmarks see here.

Bookmarks in Power BI

To read about bookmarks in Power BI please refer to Bookmarks Documentation.

Bookmarks API

In embedded report, developers can:

  • Get a list of bookmarks.
  • Apply a bookmark on report load or during session.
  • Reload a report without a bookmark applied.
  • Capture the event of bookmark applied.
  • Show/Hide the bookmarks navigation pane.
  • Enter/Exit bookmarks presentation mode.

In addition, developers can:

  • Capture and get a current view as a bookmark object.
  • Apply a captured bookmark state on report load or during a session.

Bookmark definition

interface IReportBookmark {
    name: string;
    displayName: string;
    state: string;
}

name: unique identifier of a bookmark. displayName: a display name which will appear in a bookmarks navigation pane. state: a Base64 serialization of a bookmark state. You can save it and apply it back to the report using bookmarksManager.applyState method.

Apply bookmark on load

To apply a bookmark on report load please read Embed-Configuration-Details

Code Samples

Get a list of bookmarks

    // Get a list of bookmarks
    let bookmarks = report.bookmarksManager.getBookmarks();

Apply a bookmark by name

    // apply a bookmark with a name: Bookmark1234
    report.bookmarksManager.apply("Bookmark1234");

Reload a report without a bookmark applied

    report.reload();

Capture the event of bookmark applied

    // Listen on bookmark applied event and log the applied bookmark name to browser console.
    report.on("bookmarkApplied", (event) => {
        console.log(event.detail.name);
    });

Show/Hide the bookmarks navigation pane

    // Show bookmarks navigation pane
    report.bookmarksManager.updateSettings({
        bookmarksPaneEnabled: true
    });

    // Show bookmarks navigation pane with the new panes object
    report.bookmarksManager.updateSettings({
        panes: {
            bookmarks: {
                visible: true
            }
        }
    });

    // Hide bookmarks navigation pane
    report.bookmarksManager.updateSettings({
        bookmarksPaneEnabled: false
    });

    // Hideb ookmarks navigation pane with the new panes object
    report.bookmarksManager.updateSettings({
        panes: {
            bookmarks: {
                visible: false
            }
        }
    });

Note: bookmarksPaneEnabled will be replaced by the new panes object, please avoid using them together.

Enter/Exit bookmarks presentation mode

    // Enter presentation mode
    report.bookmarksManager.play(models.BookmarksPlayMode.Presentation);

    // Exit presentation mode
    report.bookmarksManager.play(models.BookmarksPlayMode.Off);

Capture and get a current view as a bookmark object, and apply it back on the current session

A captured state can be saved in application database, and can be applied back on a report in different sessions. Managing permissions and usage of the new bookmark is done by the application.

Capture bookmark
    // Capture the current view
    let capturedBookmark = report.bookmarksManager.capture();
Capture bookmark with personalize visuals**

If you want to capture personalize visuals changes as part of the bookmark state, you will need to call capture and pass true for the personalizeVisuals option.

    interface ICaptureBookmarkOptions {
        personalizeVisuals?: boolean;
    }
    // Capture the current view with personalize visuals
    let capturedBookmarkWithPersonalizeVisuals = report.bookmarksManager.capture({
        personalizeVisuals: true
    });
Apply captured bookmark state
    // Applied previously captured state
    report.bookmarksManager.applyState(capturedBookmark.state);

Important: When using the bookmark APIs, changes to the report may cause an error or an unexpected result. For example, changes to the report may include removing report filters. To avoid errors in this example, the corresponding filters cards should be present. Instead of removing the filters you should set their values to “all”. If you don’t know which filters were deleted or changed, you can recapture the bookmark after the changes to the report were applied.