Symptom
- The "Application.setTheme(themeId)" function may fail when called in the onInitialization script of an ODE story.
- In stories based on other models or with the same model under other conditions the same script call may work as expected
- The error message observed in the console log is: "Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'toString')."
- Error may block execution of other script functions or story features and therefore block the display of the story.
Environment
- SAP Analytics Cloud 2025.14.8
Reproducing the Issue
- Create a theme in SAP Analytics Cloud.
- Add the following code to the a script in a story:
```javascript
// Apply Theme
Application.setTheme(ThemeID);
```
- In some stories the theme is applied successfully, but fails in a different story.
- Check the console log for the error message: "Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'toString')."
Cause
The issue stems from a fix for an issue where the setTheme API call incorrectly enabled the Undo / Redo in stories.
This issue is not consistently reproducible with every call of the setTheme API; it only occurs under specific timing conditions.
This issue occurred primarily under conditions where models were rendered more slowly. For instance, the issue was most likely seen with live models, or other factors causing the story to render more slowly than those using a local model.
This delay results in the script executing before the ThemeManager._clearUndoRedoStack has acquired the necessary stackId and resulted in this error.
Root Cause Analysis
Why this issue happened?
A code issue in setTheme API caused this issue. The code missed processing stackId since sometimes it is undefined
-
Why the test case did not cover this scenario?
In our test cases, we used local models, which resulted in faster story loading, preventing the issue from occurring. -
Why the regression test case not fully executed?
This issue is quite elusive. It doesn't manifest with a local model or even with a live data model similar to the customer's if the story loads quickly. The problem only occurs under a specific timing condition.
Preventive Measures
Test cases are updated to check the issue
Resolution
This issue has been resolved in the 2025.14.9 patch release.
Keywords
application.settheme, onInitialization, live data model, acquired data model, sap analytics cloud, theme application failure, console error, cannot read properties of undefined, story cache, unified story theme. , KBA , LOD-ANA-UNS-THM , Unified Story Theme , LOD-ANA-DES , Story Design & Visualizations , LOD-ANA-AD , Analytics Designer , Problem
SAP Knowledge Base Article - Public