Technical Articles
How to use Bookmark in Analytic Application SAC Planning with JavaScript
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.
- 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.
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
Thanks marc, it would helpful for developer.
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!
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
Hi James
Thanks for your answer - somehow I did not get notified of your response and only just saw it in 'SAP for Me' as notification.
Am I understanding you correctly in that you'd have to fill dropdowns manually in order to save their states as a bookmark?
I was hoping there would be a solution to save input control states - which would seem to be the go-to solution?
In case there's only the dropdown approach that would be too much of a workaround for what it would offer. In that case and given Story 2.0 is "around the corner" I'd probably go for a Story where this works out of the box.
Thanks for your help though!
Best,
Kevin
Hello All,
I implementing a interface for creating / maintaining bookmarks within SAC Applications , for the creation of the bookmark I use the saveBookmark API as following:
BookmarkSet.saveBookmark({name:l_bmkName, isDefault:l_default, isGlobal :l_global}, false);
for modifying existing bookmarks I use the same API by changing the overwrite parameter to true as following:
BookmarkSet.saveBookmark({name:l_bmkName, isDefault:l_default, isGlobal :l_global}, true);
the issue is that if I try to convert an existing personal bookmark to Global ( by setting the value of the l_global = true) the API doesn't overwrite the existing bookmark by converting it to Global but instead creates a new global bookmark with the same name and different id...
has anybody experienced the same? has anybody a solution?
Regards
here is the reply from SAC:
Bookmark saving API cannot override a bookmark that has the same bookmark name, but has different isGlobal properties. This behavior is by design. In a word, two bookmarks that have the same name but have different isGlobal properties is treated as two different bookmarks.
anyway, you can use scripts to remove bookmarks that have special names.
Regards