How do I use WebData?

Here is the structure of my Variable

want to monitor MultiView_1. I need to execute certain logic when its activeViewIndex = 3. However, when I run this code:

const webdataMode = API.WEBDATAMONITOR.getWebdata(“App.Page_1.MultiView_1”); console.log(webdataMode)

an error occurs stating that Page_1 cannot be recognized. How can I fix this issue?

Honestly, there are barely any relevant tutorials available, which is really frustrating.

You can refer the API Documentation,

no any about webdata sample

  1. You should first create webappdata. Webappdata is a feature of container-type components. Create webappdata in the behavior panel of the container-type component.

  1. You can click on the name of this webappdata, and it will be automatically copied to the clipboard. Note that the view_xxx items on the variable panel refer to container-type components and their container IDs. They do not belong to webappdata, so you cannot copy them. However, they still appear on the variable panel because they might further nest container components, and their presence is retained to reflect the hierarchical structure.

  1. Next, you can use this webappdata to set, get, and monitor.

Namespace: How to use Webdata

  • Set: API.WEBDATAMONITOR.setWebdata("App.Page_1.MultiView_1.mvindex", String(default_v))
  • Get: API.WEBDATAMONITOR.getWebdata("App.Page_1.MultiView_1.mvindex");
  1. If you want your component to subscribe to this webappdata and dynamically display the specified view, you can mount it in your onMounted method.
API.WEBDATAMONITOR.monitorWebdata(
  "App.Page_1.MultiView_1.mvindex",
  (rawValue) => {
    const numValue = Number(rawValue); 

    if (!isNaN(numValue)) {
      this.activeViewIndex = numValue;
    }
  }
);

Note: The type of webappdata value is string.

Here is the project sample: https://abbissp01sastaasblb0749.blob.core.windows.net/appstudioproduct/assets/forum-resources/14995-webappdatademo.asppag