It looks like the service tier in 2009 Sp1 is populating the TIme and CurrentDate based on GMT time and not based on local in C/Side.
In my example. Onrelease of Sales order the following code is run.
"Release Date" := Today;
"Release Time" := Time;
The problem is that from if you go and look at the order, it's released 5 hours in future. The client is on Eastern time zone.
I did a quick test webservice function and getcurrentdatetime
returnvalue := substrno('Current time is %1, date %1, Datetime%1',today,time,currentdatetime);
and it again returns future tune and datetime.
It looks like a bug.
I did see this thread
viewtopic.php?f=32&t=33833&hilit=date+time+webservice
but it's pre 2009 sp1.
Ahmed Rashed Amini
Independent Consultant/Developer
blog:
https://dynamicsuser.net/nav/b/ara3n
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
on release of sales order the code is executed. the client connected to webservice does not have access to the code.
If you for example have oninsert trigger of a table. Date time inserted, webservice will insert the GMT time
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
TIME does not return local time, since this is a webservice, it returns GMT time.
same applies to datetime. it always returns GMT time.
I have to write the code differently. to something like this.
if isServicetier or "iswebservice" then
"Tme Inserted" := TIme - 8hr
else
"time Inserted" := time;
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I'm running into the same problem. Is this going to be fixed by Microsoft?
To my humble opinion this is a bug.
TIME and DATETIME should look to the Date and Time settings of the server where the App Tier is running.
Regards
//This code write to time variable NAVTime current server time
IF ISSERVICETIER THEN
IF GUIALLOWED THEN BEGIN
//>>RTC execution
NavTime:=TIME;
END
ELSE BEGIN
//WEB execution
//get web app hours and minutes to text
txtTime:=FORMAT(TIME,4,2);
//take hours and minutes to separate texts
txtHours:=COPYSTR(txtTime,1,2);
txtMinutes:=COPYSTR(txtTime,3,2);
//convert or just copy time to one more time variable
EVALUATE(tmTimeUtc,txtTime);
//Convert time to UTC and get hours
txtHoursUTC:=COPYSTR(FORMAT(tmTimeUtc,0,9),1,2);
// convert hoursUT and hours to integer
EVALUATE(intHoursUTC,txtHoursUTC);
EVALUATE(intHours,txtHours);
// calculate difference between UTC and local time and add difference to web service time
intHours:=intHours+intHours-intHoursUTC;
//create local time based on UTC + time zone
EVALUATE(NavTime,FORMAT(intHours)+txtMinutes);
END
ELSE BEGIN
//>>CC execution
NAVTime:=Time;
I always had the assumption that we had the Middle Tier (Business Layer) to ensure all client execute the same code.