Email Logging - UTC date Conversion

Mauddib
Member Posts: 269
Hi all, any ideas on this one?
All client computers and Server computers are set to UTC + 1 Time Zones. Navision 2015.
Email logging CU5064 has a function as follows:
Problem is: The Date it is returning is 2 hours in the past. That is to say if the email was received at 1600, the code is putting 1400 into SegLine.Date.
Is there an error in this code here? Or is it possible (how to check this) that Exchange is NOT giving UTC time as the code expects?
If I change the DateTimeKind.Local to DateTimeKind.Utc then I get the correct result!!! But I would rather not change the code if the error lies elsewhere.
All client computers and Server computers are set to UTC + 1 Time Zones. Navision 2015.
Email logging CU5064 has a function as follows:
UpdateSegLine(VAR SegLine : Record "Segment Line";Emails : Code[10];Subject : Text;DateSent : DotNet "System.DateTime";DateReceived : DotNet "System.DateTime";AttachmentNo : Integer) InformationFlow := SegLine."Information Flow"; SegLine.VALIDATE("Interaction Template Code",Emails); SegLine."Information Flow" := InformationFlow; SegLine."Correspondence Type" := SegLine."Correspondence Type"::"E-Mail"; SegLine.Description := COPYSTR(Subject,1,MAXSTRLEN(SegLine.Description)); IF SegLine."Information Flow" = SegLine."Information Flow"::Outbound THEN BEGIN LineDate := DateSent; SegLine."Initiated By" := SegLine."Initiated By"::Us; END ELSE BEGIN LineDate := DateReceived; SegLine."Initiated By" := SegLine."Initiated By"::Them; END; // The date received from Exchange is UTC and to record the UTC date and time // using the AL functions requires datetime to be of the local date time kind. LineDate := LineDate.DateTime(LineDate.Ticks,DateTimeKind.Local); SegLine.Date := DT2DATE(LineDate); SegLine."Time of Interaction" := DT2TIME(LineDate); SegLine.Subject := COPYSTR(Subject,1,MAXSTRLEN(SegLine.Subject)); SegLine."Attachment No." := AttachmentNo; SegLine.MODIFY;
Problem is: The Date it is returning is 2 hours in the past. That is to say if the email was received at 1600, the code is putting 1400 into SegLine.Date.
Is there an error in this code here? Or is it possible (how to check this) that Exchange is NOT giving UTC time as the code expects?
If I change the DateTimeKind.Local to DateTimeKind.Utc then I get the correct result!!! But I would rather not change the code if the error lies elsewhere.
0
Comments
-
I expect you already checked wheather the ServiceUser has some weird Time-Settings?
Else i'd suggest to just quickly fire up VisualStudio and try it on your own, but to be honest, changing it from local to utc is an ok change if it works for you imo.
/wisaAustrian NAV/BC Dev0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions