Skip to Content

SAPUI5 Offline - How do I filter the definingRequest

I'd like to make use of SAP Cloud Platform's built in offline functionality.

Unfortunately the data will be far too large to implement offline, so I need to apply a filter to my defining requests.

"sap.mobile": {
"_version": "1.1.0",
"definingRequests": {},
"stores": [
    {
        "name": "ZSV_SURVEY_SRV",
        "serviceRoot": "/SAPUI5-ABAP-SFI/",
        "definingRequests": {
            "SurveySet": "/Surveyset"
        }
    }
]

I know I can setup a filter as follows:

SurveySet$Filter=userID.

How is userID passed in though?

E.g it would ideally filter on the logged in user's records

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Nov 24, 2017 at 03:19 PM

    Hi .

    The filter will not necessarily always be on userId. Just when offline.

    For example, the entity I'm referring to is RESULTS of a SURVEY (sorry this doesn't match my example.

    When online, managers etc would want to view ALL results, they haven't stipulated they need offline for this.

    However when completing the surveys (e.g. offsite, then offline is requested, but only for the user in question.

    Anyway, here's the solution I found.... (component.js)

    var _sapClient = "test";var oManifestUi5 = this.getMetadata().getManifestEntry("sap.mobile"); 
    oManifestUi5.stores[0].definingRequests.SurveySet = "/SurveySet?filter=" + _sapClient;

    .

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 24, 2017 at 03:08 PM

    The access to the odata service will be based on user logged on to the app right? i.e anyway he will be downloading the data specific to him. Then, why you need to put a filter in the query as userID?

    If you can explain the use case maybe I can help you better.

    Regards,
    Midhun VP

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 07, 2017 at 10:20 AM

    Hi Midhun,

    i given my given define requests as "

    "definingRequests": {

    "Dispositions": {

    "dataSource": "mainService", "path": "/Dispositions?$filter=FromDate eq datetime'2017-12-05T00:00:00'&$expand=OrderOperations/SubOperations"

    }

    }

    when im trying to read response data with model read , read function is not going to success to error please check below code for model read

    filter.push(new sap.ui.model.Filter("FromDate", "EQ",date));

    oModel.read("/Dispositions", {

    filters: filter,

    urlParameters:{"$expand" :"OrderOperations/SubOperations"},

    success: function(oMasterData) {


    }, error:function(error){

    }

    Can you please suggest me what will be an issue, will appreciate your reply.

    Regards,

    Saleem

    Add comment
    10|10000 characters needed characters exceeded