SAP Knowledge Base Article - Public

3547931 - Issue with Array Script Variables Not Saving in Bookmarks in SAP Analytics Cloud

Symptom

  • In SAP Analytics Cloud, array script variables of type string are filled via script.
  • After creating a bookmark and reopening it, the script variables are found to be empty.
  • The expected behavior is that the script variables should retain the value when the bookmark was created.

Environment

SAP Analytics Cloud

Reproducing the Issue

  1. Open a story in SAP Analytics Cloud.
  2. Use array operation e.g. push() to pass the array.
  3. Bookmark the current state.
  4. Open the bookmark.
  5. The array variable was missing (turns empty in console log).

Cause

Script variables can not be bookmarked for some array operation like "push()",  its value can only be bookmarked via using assignment expression ("="). 

Also you cannot bookmark changes you make to the non-primitive type script variables (types other than string, boolean, integer, and number).

Resolution

As a workaround, please consider to use array operations like slice() to clone the source array first and use "=" to assign to the target array. 

Or you may consider to assign the widget's name(string, like "Chart_1") to the array, and later use "Application.getWidgets" to retrieve this widget instance by using name. For example as below:

    ScriptVariable_1 = "Chart_1";
    var chart = Application.getWidgets({searchPattern: ScriptVariable_1, type: WidgetType.Chart})[0];
    chart.setVisible(false);

See Also

Your feedback is important to help us improve our knowledge base.

Keywords

SAP Analytics Cloud, array script variables, bookmark, empty variables, data analysis, visualization, scripts, console log, missing variable, bookmark state. , KBA , LOD-ANA-AD-INF , Analytics Designer Infrastructure , LOD-ANA-UNS-SCR , Unified Story Scripting related Issues , Problem

Product

SAP Analytics Cloud all versions