Outlook Appointment from NAV, Time defaults to 00:00 in RTC
kakis
Member Posts: 7
Hi all,
I have been lurking these forums for a long time and you guys have helped me overcome a lot of issues we were facing, but I did not find anything related to what I am going write next.
I have created a codeunit which you can call from various tables to create Outlook Appointments.
However the Time of the Appointment Item.Start attribute always defaults to midnight (00:00). As a result I cannot really create Appointments automatically for them and I have to pop up the Calendar Window so that they can manually select the time.
Please note this happens only when the Codeunit is called from the RTC Client. If we use the Classic the time is set correctly.
Please find the code below.
IF NOT CREATE(Application,FALSE,TRUE) THEN
EXIT;
char13 :=13;
char10:=10;
//text:= text1 +format(char13)+format(char10)+ text2;
Namespace := Application.GetNamespace('MAPI');
Namespace.Logon;
"Appointment Item" := Application.CreateItem(1);
"Appointment Item".Start(DATI2VARIANT(date,120000T));
"Appointment Item".Subject := Type+ ' - ' + Name+' - ' +"Name 2";
"Appointment Item".Body := 'This is an automated appointment sent from NAV.'+FORMAT(char13) + FORMAT(char10) +
'Phone number(s): ' + "Phone No." + ' . ' + "Mobile Phone No.";
"Appointment Item".Duration := 60;
"Appointment Item".ReminderMinutesBeforeStart := 1;
"Appointment Item".ReminderSet := TRUE;
"Appointment Item".Location := 'Phone';
"Appointment Item".Display;
//"Appointment Item".Save;
Namespace.Logoff;
CLEAR(Application);
As you can see I commented off the "Save" and replaced it with "Display" in order for the window to pop up.
Any kind of input will be appreciated!
I apologise in advance if something is not clear, English is not my first language.
Regards
Constantine
I have been lurking these forums for a long time and you guys have helped me overcome a lot of issues we were facing, but I did not find anything related to what I am going write next.
I have created a codeunit which you can call from various tables to create Outlook Appointments.
However the Time of the Appointment Item.Start attribute always defaults to midnight (00:00). As a result I cannot really create Appointments automatically for them and I have to pop up the Calendar Window so that they can manually select the time.
Please note this happens only when the Codeunit is called from the RTC Client. If we use the Classic the time is set correctly.
Please find the code below.
IF NOT CREATE(Application,FALSE,TRUE) THEN
EXIT;
char13 :=13;
char10:=10;
//text:= text1 +format(char13)+format(char10)+ text2;
Namespace := Application.GetNamespace('MAPI');
Namespace.Logon;
"Appointment Item" := Application.CreateItem(1);
"Appointment Item".Start(DATI2VARIANT(date,120000T));
"Appointment Item".Subject := Type+ ' - ' + Name+' - ' +"Name 2";
"Appointment Item".Body := 'This is an automated appointment sent from NAV.'+FORMAT(char13) + FORMAT(char10) +
'Phone number(s): ' + "Phone No." + ' . ' + "Mobile Phone No.";
"Appointment Item".Duration := 60;
"Appointment Item".ReminderMinutesBeforeStart := 1;
"Appointment Item".ReminderSet := TRUE;
"Appointment Item".Location := 'Phone';
"Appointment Item".Display;
//"Appointment Item".Save;
Namespace.Logoff;
CLEAR(Application);
As you can see I commented off the "Save" and replaced it with "Display" in order for the window to pop up.
Any kind of input will be appreciated!
I apologise in advance if something is not clear, English is not my first language.
Regards
Constantine
0
Comments
-
What I remmember is, that in some versions and in some automations, the datetime parameter was presented as date parameter in NAV (thus cutting the time...). There were special automations to just go around this issue (wrappers) to set the date and time correctly. Under RTC, you can try to use the DotNet instead automations.0
-
Thanks for the reply, I was hoping I was doing something wrong.. ](*,) Ah well I ll have to play around some more then.
Thank you for helping!0 -
But I am not sure if this is the situation, because I see .Start as Variant, not Date...
When I looked into Codeunit 5073 from NAV 4, I see>AppointmentItem.AllDayEvent := Todo."All Day Event" ; AppointmentItem.Subject := Todo.Description; AppointmentItem.Location := Todo.Location; AppointmentItem.Importance := Todo.Priority; StartTime := SkipSeconds(Todo."Start Time"); AppointmentItem.Start := DATI2VARIANT(Todo.Date,StartTime); AppointmentItem.Duration := ROUND(Todo.Duration / 60 / 1000,1); AppointmentItem.AttainDbCompanyName := COMPANYNAME; AppointmentItem.AttainSalespersonCode := Todo."Salesperson Code"; AppointmentItem.AttainTodoNo := Todo."No."; AppointmentItem.AttainContextURL := OutlookContactHandler.CreateTaskLink(Todo."Organizer To-do No."); AppointmentItem.AttainTodoVersionNo := Todo."Version No.";
It means it should work. Try first to add this"Appointment Item".AllDayEvent := False;
before you set the Start...0 -
Tried it, still defaults to 00:00..
Ah well, I ll try to redo the whole thing but with using DotNet variables instead of Automation variables.
Lets see how that will go.0 -
Long time overdue. Using dotNet variables in rtc solved the problem.
This is the code I used:
outlookApp := oAppClass.ApplicationClass();
oAppointment := oAppointmentClass;
oAppointment := outlookApp.CreateItem(1);
oAppointment.Subject := Subject;
oAppointment.Body := Body;
//oAppointment.Location := 'Appointment location';
// Set the start date
oAppointment.Start := CREATEDATETIME(StartDate,StartTime);
// End date
oAppointment."End" := CREATEDATETIME(StartDate,EndTime);
// Set the reminder 15 minutes before start
oAppointment.ReminderSet := TRUE;
oAppointment.ReminderMinutesBeforeStart := 15;
//Setting the sound file for a reminder:
oAppointment.ReminderPlaySound := TRUE;
//set ReminderSoundFile to a filename.
//Setting the importance:
//use OlImportance enum to set the importance to low, medium or high
//oAppointment.Importance := Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
//oAppointment.BusyStatus := Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;;
//oAppointment.Save();
oAppointment.Display(oAppointment);
Parameters:
Var Name DataType Subtype Length
No Subject Text 1000
No Body Text 1000
No StartTime Time
No EndTime Time
No StartDate Date
No location Text 1000
Variables:
Name DataType Subtype Length
outlookApp DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.Application
oAppClass DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.ApplicationClass
oAppointment DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.AppointmentItem
oAppointmentClass DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.AppointmentItemClass
olItemType DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.OlItemType
oMailItem DotNet 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.MailItem0 -
Hi Kakis,
not sure if you already solved the problem, and how urgent this is for your customer, but we had the same kind of problems before. Things not working properly in the integration, no debugging possible, and not flexible.
We have created a new NAV-Outlook Synchronisationautomation where you, as a developper, can make changes very easy.
Perhaps this could be interesting for you.
See our website http://www.vssolutions.nl
If you still have this issue, and your customer wants you to fix it: here's your solution
Ernsthttp://www.vssolutions NAV-Outlook synchronisation re-invented.0 -
Hi Kakis,
Did you get this to work setting the start time and end time of an outlook meeting?
I have tried using your method with a dotnet variable and even though in NAV it has the correct time e.g. StartTime = 1600T when the actual meeting is created it seems to read the time incorrectly and creates a meeting at 0600 AM
I have tried also changing my regional date and time settings on the computer/server so that they are all in 24 hour format as well but still no difference.
0 -
Just figured this out. The timezone that was trying to recalculate the start time according to UTC...
Changed the call to this and it worked!
oAppointment.StartUTC := CREATEDATETIME(StartDate,StartTime);
oAppointment.EndUTC := CREATEDATETIME(StartDate,EndTime);0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 328 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
