SAP Knowledge Base Article - Public

3544051 - NavigationUtils.openStory and openUrl are not working in onInitialization() event

Symptom

The following APIs are called in onInitialization() event, they are not working after system upgrade.
- NavigationUtils.openStory
- NavigationUtils.openUrl(XXX,false)

F12 console errors:

- Script execution failed for event "Application.onInitialization" 
- STORE_COMMIT_TRANSACTION/1 failed as store has been destroyed
- Uncaught (in promise) SET_BUSYINDICATOR_VISIBILITY@[{"app":"MAIN_APPLICATION"}] failed as store has been destroyed

Environment

SAP Analytics Cloud

Reproducing the Issue

Call NavigationUtils.openStory/openUrl(XXX,false) in onInitialization() event.

Cause

Calling NavigationUtils.openStory/openUrl(XXX,false) is not recommended becausenavigating to a new story (openStory) or opening a new app in current tab(openUrl(XXX,false)) will destroy previous/current script engine context, but due to asynchronous feature of javascript in frontend, there will be still potentially some async task in onInitialization() to be queued and executed after calling the APIs which lead to the error. These code might work well before but it's just not guaranteed to be predictable.

Resolution

To achieve more stable script execution behavior, you can use a timer to delay the calling of "NavigationUtils.openStory/openUrl".

  1. Use a timer to call "NavigationUtils.openStory/openUrl".

  2. Move the navigating logic into timer's onTimeout() event.

  3. Call the timer in onInitialization() event like "Timer_1.start(1);"

Keywords

Analytic Designer, SAC, application, script, onInitialization, openStory, openUrl , KBA , LOD-ANA-AD , Analytics Designer , LOD-ANA-UNS-SCR , Unified Story Scripting related Issues , Problem

Product

SAP Analytics Cloud 1.0