Skip to Content

How to call Odata with input parameter

Hi experts,

I'm quite new to Fiori and Sapui5.

Im developing an application starting from Master-Detail template. I need to connect to an Odata service which requires an id as input to give me results.

I'mo not sure how and where to write the code to pass the input. I thought that this wuold be in manifest.json or component.js since in manifest there is the datasource definition with the uri and in the component there is the call to the getModel() but what I tried so far did not work.

I don't know what code you need to understand my problem so I would wait for your reply and your request to post the necessary part of the code.

Thank you

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jun 29, 2017 at 03:07 PM

    Hi,

    I managed to get the data, but now I have trouble to save them in my models.

    These are the instructions I used inside Component.js:

    var aFilterIds = ["AppraiseeId"];
    var aFilterValues = ['00000108'];
    var aFilters = this._createSearchFilterObject(aFilterIds, aFilterValues);
    var mParameters = {
        filters : aFilters,
        success : function (oData) {}.bind(this),
        error: function (oError) {}.bind(this)
    };
    this.oAppModel = this.getModel().read("/HrLists", mParameters);
    

    After the read(), I get this in console:

    Object { abort: abort() }

    But I can read, from the POST response all the data I need:

    I tried defining oAppData as JSONModel and ODataModel.

    If I remove the filter from the Odata service, and I call then the service with:

    this.oAppModel = this.getModel();

    the app works like a charm.

    Any ideas?

    Thank you

    Add comment
    10|10000 characters needed characters exceeded