on 2023 Sep 22 6:32 AM
Hello everyone,
I am developing a custom widget for the SAC and want to use the Analytics Designer API (https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html).
In my case I want to be able to change the viewed story from the inside of my custom widget code. So I defined a function that looks like this:
class Widget extends HTMLElement {
changeStory(storyId,pageId){
NavigationUtils.openStory(storyId,pageId);
}
...
}
The problem that I face is that the call of the "changeStory"-function throws following error: Uncaught ReferenceError: NavigationUtils is not defined.
Now my question is how I could access the NavigationUtils Component from the inside of my code (https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html#NavigationUtils).
Thanks and best regards
Michael
Depends on your case. If the method does not need access to the DOM you can implement it in contribution JSON (see https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/0ac8c6754ff84605a4372468d002f2bf/bde41c0b637b49fbb4e79.... There you have access to type libraries you imported (https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/0ac8c6754ff84605a4372468d002f2bf/0dab4c7d40e64ee0b3017f06d983f3da.html). NavigationUtils is in standard library, which is always included.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could put the part where you need DOM access into a dedicated method which you implement in the web component and call that one from the other method. Not sure whether there are other options.
var value = this.getSomethingFromDom()
var url = // do something with value
NavigationUtils.openStory(...)
Hello Michael,
You may need to reference the API script in your HTML file or import it using a module system if you are using one.
// Import the Analytics Designer API (Example, actual path may vary)
import { NavigationUtils } from '@sap/analyticsdesigner';
SAC widgets often require proper initialization. Ensure that your widget is initialized correctly and that the Analytics Designer API is available at the time your widget is created.
class Widget extends HTMLElement {
constructor() {
super();
// Initialize your widget and the Analytics Designer API
// Ensure proper initialization steps are taken here
}
changeStory(storyId, pageId) {
// Use NavigationUtils.openStory here
NavigationUtils.openStory(storyId, pageId);
}
// Other widget code...
}
If you're encountering issues with undefined components, it might be due to the timing of when your widget code is executed. Make sure that you're accessing the NavigationUtils component after the necessary dependencies have loaded.
Ensure that your custom widget is compatible with the version of SAC you are using and that the API you are trying to access is available in that version.
Thanks,
Lakskhmi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.