on 07-22-2015 12:59 PM
Hi guys,
I'm using as a guide the examples found in "" by Daniel Van Leeuwen
I use run time SMP 3.0.7.3 (SP07 PL 03) and I have an issue reading from the offline store.
Although the example works perfect using the same SMP server, my customization to it doesn't.
The example index2.html. works fine :
read request started at 15:49.37 index.html:523
read using http://server:port/com.offline.demo2/(S(yq0fai1i0214nfvlw0nvmqpk))/V2/OData/OData.svc/Products?$orde... desc&$filter=sap.islocal() index.html:147
Read 1 records in 0.022 seconds at 15:49.37 index.html:523
But the request from my app doesn't:
read using http://server:port/com.etb.sfa.dev/SalesOrder?$filter=sap.islocal() Dialog.js:39
Failed to load resource: the server responded with a status of 400 (Bad Request) http://server:port/com.etb.sfa.dev/SalesOrder?$filter=sap.islocal()
Both Apps are connected to the same SMP server and port and the code for the requests is similar:
My code:
onReadOfflinePress : function(oEvent){
var sURL = getEndPointURL() + "SalesOrder?$filter=sap.islocal()";
var oHeaders = {};
oHeaders['Authorization'] = authStr;
oHeaders['X-SMP-APPCID'] = applicationContext.applicationConnectionId; //this header is provided by the logon plugin
var request = {
headers : oHeaders,
requestUri : sURL,
method : "GET"
};
console.log("read using " + sURL);
OData.read(request, readSuccessCallback, errorReadCallback);
function readSuccessCallback(data, response) {
var endTime = new Date();
var duration = (endTime - startTime)/1000;
}
function errorReadCallback(e) {
if (e.request) {
if (e.request.requestUri) {
var endTime = new Date();
var duration = (endTime - startTime)/1000;
var resp = e.response.requestUri;
var appIdRequest = resp.substr(resp.search(appId), 100);
var request = appIdRequest.substr(appIdRequest.search("/") + 1, 100);
changeOfflineLine(request, false, duration, "e", e.message);
} else {
alert("An error occurred errorReadCallback");
alert(JSON.stringify(e));
}
} else {
alert("An error occurred errorReadCallback");
alert(JSON.stringify(e));
}
}
}
And original code:
function read(isLocal) {
updateStatus2("read request started");
startTime = new Date();
showScreen("MainDiv");
clearTable("ProductsTable");
if (!haveAppId()) {
return;
}
var sURL = getEndPointURL() + "/Products?$orderby=Name desc";
if (isLocal === true) { //displays entities that have been created or updated but have not yet been flushed.
if (store && store.getRequestQueueStatus) { //filter is a new features in SP06 of the SDK. getRequestQueueStatus was added in the same SP.
sURL = sURL + "&$filter=sap.islocal()";
}
else {
alert("Displaying changed records that have not yet been flushed requires the offline store to be open and is a new feature in SP06 of the SDK");
}
}
var oHeaders = {};
oHeaders['Authorization'] = authStr;
//oHeaders['X-SMP-APPCID'] = applicationContext.applicationConnectionId; //this header is provided by the logon plugin
var request = {
headers : oHeaders,
requestUri : sURL,
method : "GET"
};
console.log("read using " + sURL);
OData.read(request, readSuccessCallback, errorCallback);
}
Any ideas?
Regards,
Marius
Hi Marius,
not sure if you have already sorted this.
The first question would be: if you do not add the IsLocal() Statement to your URL, does it work in that casE? Usually the issue is due to a not correctly configured OffLine store.
The parameter IsLocal() only selects entries from the offline store, that you have created on the device itself. So even if you do not have this parameter, once the OffLine Store is opened, all requests will deliver the data from the internal database.
Regards,
Oliver
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.