cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 Offline - How do I filter the definingRequest

former_member239819
Participant

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

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member241395
Discoverer
0 Kudos

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

former_member239819
Participant
0 Kudos

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;

.

former_member611303
Participant
0 Kudos

hi adam,

by this process I got the answer but pls let me clear how to call "oManifestUi5" this one in definingRequest.

thanks

jai sharma

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

midhun_vp
Active Contributor
0 Kudos

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