on 10-26-2018 2:51 PM
Hello All,
I am using Webide,
So In Controller my oModel.read is not getting data from Backend system.
Please find my code here. Any suggestion?
onInit: function () {
var sServiceUrl = "/sap/opu/odata/sap/ZUI_USERCREATION_SRV/";
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);
this.getView().setModel(oModel);
var oJsonModel = new sap.ui.model.json.JSONModel();
oModel.read("/CostCenterSet",{ success: function(oData, response){
oJsonModel.setData(oData);
sap.ui.getCore().setModel(oJsonModel);
}
});
},
Hi Sujoy,
You might want to try sending key field as parameter because you are using Read method. Please take reference from below code.
You also need to update your odata method to get this parameter and pass to backend code.
onPressRead:function(){
var oView = this.getView();
var fnm = oView.byId("txtFNM1").getValue();
var oModel = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/ZEMP_SRV/");
var sPath = "/EmpSet(Empfnm='"+ fnm +"')";
oModel.read(sPath, {
success: function(oData){
MessageToast.show(oData.Empfnm + "-----" + oData.Emplnm);
},
error: function(oData){
MessageToast.show("Error");
}
});
},
For Console Information :
When you use Chrome (recommended Browser) press F12 and you will see developer tools panel will be displayed..
Hope this helps...
Thanks-
Abhishek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It would have been more helpful if u had pasted the error log from browser console..
But before that, I can see u r instantiating the odata model in Ur init method.. What I would suggest is to use the manifest.json to instantiate Ur odata model.. In manifest.json. Also, I hope if u r using cloud webide u r using cloud connector or if u r using local webide, u need to create destination files.. else while connecting to backend it gives "same origin" error..
Best regards,
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
with this information....no one can help.
did you debug? did it reach your odata service?
what the console say?.....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.