Reputation: 221
So I have implemented a function import using NW Gateway and I was pleasantly surprised to find that I could add the oData query option $expand and it worked!
Now I want to take advantage of that by passing a $expand parameter from my SAPUI5 application. But I can't find a way to make this work. My call looks something like this...
oModel.callFunction("/VehicleSearch", {
method: 'GET',
urlParameters: {"$expand": "Owner", "SearchString": searchString},
success: function(oData, response) { },
failure: $.proxy(function(oError) { }
});
The SearchString parameter is passed but not the $expand.
Upvotes: 2
Views: 7487
Reputation: 3133
You ran into a "currently" missing feature. UI5 version 1.38 adds $expand for oModel.callFunction.
A workaround is to use read instead of callFunction (add $expand to the url).
updateData: function() {
var oVizFrame = this.getView().byId("idVizFrame");
var url = "QueryLogAnalysis?viewVariant=myFavorites&$expand=Values&$format=json";
var parameters = {
success: function(oData, response) {
var resultData = JSON.parse(response.body);
var dataModel = new sap.ui.model.json.JSONModel(resultData.d.results[0]);
oVizFrame.setModel(dataModel,"expandWorkaround");
},
error: function(oError) {
console.log(oError); // i.e.
}
};
var serviceUrl = this.getView().getModel().sServiceUrl;
var oJsonModel = new sap.ui.model.odata.ODataModel(serviceUrl);
oJsonModel.read( url, parameters );
}
Upvotes: 1
Reputation: 1482
I think you can not expand a function Import. Expand is used when entities have associations and you are querying an entity which is associated with one or more of another type. The dependent entities are not automatically fetched unless you put them in the expand list. Function imports are more like function calls. In fact they're limited in what you can return.
Upvotes: 0
Reputation: 4231
I do not use OData in my current project, thus my knowledge migth not be up to date. As far as I know the $expand parameter does not work for function calls. If you check the implementation of the callFunction you'll see why only the search parameter reaches the backend: parameters not defined at the function won't be passed.
Upvotes: 1