Skip to Content
0

Issue with Dates conversion after deploying app to the SCP

Apr 12 at 06:43 PM

149

avatar image

Hello experts,

I have the next problem. I use odata version 2 for my fiori app. One of the entities contains property with type Edm.DateTime. For filtering data by date i use the next syntax:

oDate = new Date()
<...>
new sap.m.List(sId, {
<...>
filters: [new Filter("DateOfWork", "EQ", oDate)]
}
});

for format output i use formatter function as ussally:

dateFormat: function(oValue) {
//date: dd.mm.yyyy
var day = oValue.getDate();
var month = oValue.getMonth(); 
}

In WEB ide it works fine, when i deploy to abap repository it works fine as well, BUT when i deploy it to cloud platform it doesn't work. at first i get en error, because date is not converted to format required by http request for date, so it is passed just like a string and of course it doesn't work.

Then in formatter, oValue in not of js type Date (like in web ide), but string like "/Date(1404860400000)/"

I thought that probably issue is in models, but model looks the same. Do you have any idea? what can be a reason?


Best Regards,

Mikhail

10 |10000 characters needed characters left characters exceeded

Have you compared the results from odata requests made from WebIDE and from SCP's deployed app? Could this be a cache problem?

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Karthik Rayanki Apr 17 at 09:01 PM
0

Hey Mihail,

The format you specified Date(1404860400000) is a milliseconds format of data object.

The value can be accessed by following code

var a = new Date(1404860400000);

or in your case

dateFormat:function(oValue){//date: dd.mm.yyyy

var newDate = new Date(oValue);
var day = newDate.getDate();
var month = newDate.getMonth();}

you could use this way of accessing inside your dateFormat formatter. Hope this helps.


Regards,

Karthik.


Share
10 |10000 characters needed characters left characters exceeded