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());
myBookmark.setBookmark(InputField_1.getValue(),RadioButtonGroup_1.getSelectedKey());
myBookmark.getBookmark(RadioButtonGroup_1.getSelectedKey());
BookmarkSet_1.apply(Dropdown_1.getSelectedKey());
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.