Search code examples
javascriptcordovasapui5

How do you include a set with a relative path in a SAP hybrid app?


I've made an app in SAP UI5 that works in online mode when using a browser, and offline mode when using a mobile device. I'm trying to display some options in a popup that are fetched from a set. The problem is that the set is found when I run it in online mode, but not offline.

The set is an extension of another set, and depends upon a variable, e.g. /FooSet('P1')/Types, where P1 is a variable. The implementation for fetching the items from the set and displaying them in the popup is the following:

this._popup.getAggregation('_dialog').getContent()[1].bindAggregation("items", {
    path: "/FooSet('" + varType + "')/Types",
    template: new sap.m.StandardListItem({
        title: "{Title}",
        description: "{Desc}"
});

As mentioned, this works fine online, but the Types set is empty when running it offline.

I suspect that the problem lies in the definingRequests.json file, which contains all the sets that are to be included in the offline app. Here's a snippet:

{
    "definingRequests": {
        "FooSet": "/FooSet",
        "BarSet": "/BarSet",
        "ZooSet": "/ZooSet"
    }
}

Here, the three sets are included; I'm getting the correct data from FooSet, for example, which contains the different variables like P1, P2, P3 and so on. So my question is: How do I include the Types set from /FooSet('P1')/Types when there's a variable like P1 involved?

I've already tried defining it like "Types": "/Types", as well as "Types": "/FooSet/Types", but that's not working neither.

Thanks in advance!


Solution

  • As suspected, I was just defining the set incorrectly in definingRequests.json.

    It was supposed to be "TypesSet": "/TypesSet", not "Types": "/Types", even though the path is named Types. All is good now :)