Skip to Content
Technical Articles
Author's profile photo Rohit Chouhan

How to use Bookmark in Analytic Application SAC Planning with JavaScript

 

image%20source%3A%20seongon.com

If you’re an application designer, you can create a bookmark set technical object so application users can save the state of your analytical app at runtime.

image source: seongon.com

In order to dynamically create bookmarks in the analytics application, please follow the steps below.

Before staring, create Bookmark set from scripting.

  1. First create one popup with components inside.
Component Component Name
InputField InputField_1
RadioButton RadioButtonGroup_1
Dropdown Dropdown_1
Button Button_1, Button_2, Button_3

 

 

Radio Button Group Value:

id Value
false Personal
True Global

2. Create ScriptObject with two script function, with name myBookmark

  • getBookmarkCreate one Arguments, with return type void.
Argument Name Type
type string

Add this below code in getBookmark()

var bookmarks = BookmarkSet_1.getAll(); 
Dropdown_1.removeAllItems();

var globalType = false;
if(type==="true"){
	globalType = true;
}

for (var i =0 ; i<bookmarks.length;i++){
	if(bookmarks[i].isGlobal === globalType){
		Dropdown_1.addItem(bookmarks[i].id,bookmarks[i].name);
	}
}

if(bookmarks.length>=1){
	Dropdown_1.setSelectedKey(bookmarks[0].id);
}
  • setBookmarkCreate two Arguments, with return type void.
Argument Name Type
name string
type string

Add this below code in setBookmark()

var globalType = false;
if(type==="true"){
	globalType = true;
}

BookmarkSet_1.saveBookmark({name: name, isGlobal: globalType});
Application.showMessage(ApplicationMessageType.Success,InputField_1.getValue()+" Bookmark Saved");

3. Add this all code inside all components mentioned below

  • RadioButtonGroup_1
myBookmark.getBookmark(RadioButtonGroup_1.getSelectedKey());
  • Button_1
myBookmark.setBookmark(InputField_1.getValue(),RadioButtonGroup_1.getSelectedKey());
myBookmark.getBookmark(RadioButtonGroup_1.getSelectedKey());
  • Button_2
BookmarkSet_1.apply(Dropdown_1.getSelectedKey());
  • Button_3
BookmarkSet_1.deleteBookmark(Dropdown_1.getSelectedKey());
Application.showMessage(ApplicationMessageType.Success,Dropdown_1.getSelectedText()+" Bookmark Deleted");
myBookmark.getBookmark(RadioButtonGroup_1.getSelectedKey());

4. Create new Button in Canvas, and open popup with this code

Popup_1.open();

 

Conclusion

In the case of multiple components or filters, we have to save our application states multiple times, so bookmarking is the best way to save multiple states quickly.

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Marc Kuipers
      Marc Kuipers

      Hello Rohit Chouhan

       

      Good blog!

      Just as an additional comment - as we see a lot of issues with this.

      A user will need the permission to create a bookmark, even a private one. Without this, the saveBookmark() API will fail with an unclear error message

       

      Author's profile photo Rohit Chouhan
      Rohit Chouhan
      Blog Post Author

      Thanks marc, it would helpful for developer.

      Author's profile photo Kevin Maurer
      Kevin Maurer

      Thanks Rohit for this tutorial. I tried to implement it in a standard Application (not planning) which was very easy following your guide, however, it does not seem to be saving / applying the filters.

      I can close and re-open the application - the bookmarks are loaded again (although it takes too long for my liking until dropdown is populated). Unfortunately, once I apply a bookmark it just reloads the application but the filter settings are not applied.

      Do you have any hints / tips? Is this approach only possible for planning?

      Thanks for your help!

      Author's profile photo James Barlow
      James Barlow

      Bookmarking with filters does get a bit more tricky,

      If you have more details I might be able to help.

      I created an analytic app for a customer that used dropdowns to filter the dashboard, the challenge was to ensure that the selected value in the dropdown - was

      1. captured during bookmarking
      2. the bookmarked dropdown value then needed to be stored in a variable
      3. then the filter re-applied when the bookmark was opened.

       

      James