on 01-13-2015 1:08 AM
Hi,
This is my code. I want to do an update. However, I am facing this issue -"ReferenceError: OData is not defined".
function ajaxWrite(link, parameters){
OData.request
({
requestUri: link,
method: "GET",
headers:{
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/atom+xml",
"DataServiceVersion": "2.0",
"X-CSRF-Token":"Fetch"
}
},
function (data, response){
OData.request
({
requestUri: link,
method: "PUT",
headers: {
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/atom+xml;type=entry; charset=utf-8",
"DataServiceVersion": "2.0",
"Accept": "application/atom+xml,application/atomsvc+xml,application/xml",
"X-CSRF-Token": response.headers['x-csrf-token']==undefined? response.headers['X-CSRF-Token']: response.headers['x-csrf-token']
},
data: parameters
},
function (data){
success();
// refresh the timeline
sap.ui.getCore().getModel("timelineModel").loadData(URL.Timeline.link, '', false);
loadTimeline();
},
function (err){
error(null, "Error in PUT operation");
}
);
},
function (err){
error(null, "Error in GET operation");
}
);
}
I do an update like this:
var oModel = new sap.ui.model.odata.ODataModel("..........URL OF SERVICE.....", true);
oModel.update("/Entity("+id+")", data, null, function(){}, function(){});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes better to use OData model CRUD functions as documented here OData Write Support - SAPUI5 Developer Guide - SAP Library
Regards,
Chandra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.