Appointment Objekt

Beispiel VBScript:

Dim oProject : Set oProject = cRM.CurrentProject

Dim oActiveView : Set oActiveView = cRM.CurrentProject.ActiveViews.ActiveView

Dim oViewConfig : Set oViewConfig = oActiveView.Config

Dim oRecord : Set oRecord = oActiveView.CurrentRecordSet.CurrentRecord

Dim sCurrentUserLoginName : sCurrentUserLoginName = oProject.Users.CurrentUser.LoginName

Dim sPrimaryKeyFieldName : sPrimaryKeyFieldName = oViewConfig.PrimaryKeyFldName

Dim sRecordRefDescription : sRecordRefDescription = oRecord.GetRecordRefDescription

Dim sRefLink : sRefLink = oProject.ID & "|" & oActiveView.Name & "|" & oViewConfig.FamilyName & "|" & sPrimaryKeyFieldName & "|" & oRecord.GetContentsByName(sPrimaryKeyFieldName) & "|" & sRecordRefDescription

Set oRecord = Nothing

Set oViewConfig = Nothing

Set oActiveView = Nothing

Set oProject = Nothing

 

Dim oAppointment : Set oAppointment = cRM.CurrentProject.timemanager.Appointments.Add()

 

oAppointment.ActionData = "info@relationship-manager.net"

oAppointment.ActionID = "TMMAIL"

oAppointment.ActionType = "1"

oAppointment.AllDayEvent = False

oAppointment.Attendees.Add("LFrisch")

oAppointment.Attendees.Add("THeld")

oAppointment.Body("{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1031{\fonttbl{\f0\fnil\fcharset0 Calibri;}}{\*\generator Riched20 10.0.22000}\viewkind4\uc1 \pard\sa200\sl276\slmult1\i\f0\fs22\lang7 Formatierter \b\i0 Inhalt/Text \b0 des \ul Termins\ulnone\par}")

oAppointment.Categories.Add("Meeting")

oAppointment.ChangeDate(Now())

oAppointment.ChangeUser(sCurrentUserLoginName)

oAppointment.Contact("Kontakt, mit dem der Termin stattfindet")

oAppointment.CreationDate(Now())

oAppointment.CreationUser(sCurrentUserLoginName)

oAppointment.End(DateAdd("h", 2, Now()))

oAppointment.ExtUserData1 = "Erster Abschnitt von Zusatzinformationen"

oAppointment.ExtUserData2 = "Zweiter Abschnitt von Zusatzinformationen"

oAppointment.HostDataBase = sRefLink

oAppointment.Importance = 3

oAppointment.IsRecurring = True

oAppointment.Location = "Büro"

oAppointment.Private = False

oAppointment.Reminder = True

oAppointment.ReminderMinutesBeforeStart = 30

oAppointment.Start(DateAdd("h", 1, Now()))

oAppointment.Subject = "Priorität" & oAppointment.Importance & ": Meeting im Büro mit " & sRecordRefDescription

oAppointment.TimeStamp = FormatDateTime(Now(), vbGeneralDate)

oAppointment.User = sCurrentUserLoginName

 

Call oAppointment.Save()

Call oAppointment.Display()

 

Set oAppointment = Nothing

Beispiel C#-Script:

Project currentProject = cRM.CurrentProject;

View activeView = currentProject.ActiveViews.ActiveView;

ViewConfig activeViewConfig = activeView.Config;

Record currentRecord = activeView.CurrentRecordSet.CurrentRecord;

string currenUserLoginName = currentProject.Users.CurrentUser.LoginName;

string primaryKeyFieldName = activeViewConfig.PrimaryKeyFldName;

string recordRefDescription = currentRecord.GetRecordRefDescription();

string refLink = currentProject.ID + "|" + activeView.Name + "|" + activeViewConfig.FamilyName + "|" + primaryKeyFieldName + "|" + currentRecord.GetContentsByName(primaryKeyFieldName) + "|" + recordRefDescription;

currentRecord.Dispose();

activeViewConfig.Dispose();

activeView.Dispose();

currentProject.Dispose();

 

Appointment appointment = currentProject.TimeManager.Appointments.Add();

 

appointment.ActionData = "info@relationship-manager.net";

appointment.ActionID = "TMMAIL";

appointment.ActionType = 1;

appointment.AllDayEvent = false;

appointment.Attendees.Add("LFrisch");

appointment.Attendees.Add("THeld");

appointment.Body = @"{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1031{\fonttbl{\f0\fnil\fcharset0 Calibri;}}{\*\generator Riched20 10.0.22000}\viewkind4\uc1 \pard\sa200\sl276\slmult1\i\f0\fs22\lang7 Formatierter \b\i0 Inhalt/Text \b0 des \ul Termins\ulnone\par}";

appointment.Categories.Add("Meeting");

appointment.ChangeDate = System.DateTime.Now.ToString();

appointment.ChangeUser = currenUserLoginName;

appointment.Contact = "Kontakt, mit dem der Termin stattfindet";

 

appointment.End = System.DateTime.Now.AddHours(2);

appointment.ExtUserData1 = "Erster Abschnitt von Zusatzinformationen";

appointment.ExtUserData2 = "Zweiter Abschnitt von Zusatzinformationen";

appointment.HostDatabase = refLink;

appointment.Importance = 3;

appointment.Location = "Büro";

appointment.Private = false;

appointment.Reminder = true;

appointment.ReminderMinutesBeforeStart = 30;

appointment.Start = System.DateTime.Now.AddHours(1);

appointment.Subject = "Priorität " + appointment.Importance + ": Meeting im Büro mit " + recordRefDescription;

appointment.TimeStamp = System.DateTime.Now.ToString();

appointment.User = currenUserLoginName;

 

RecurrencePattern recurrencePattern = appointment.RecurrencePattern;

recurrencePattern.RecurrenceType = 2; // Monatliche Wiederholung;

recurrencePattern.DayOfMonth = 10;

recurrencePattern.Duration = 60;

recurrencePattern.EndTime = System.DateTime.Now.AddMinutes(30);

recurrencePattern.Interval = 1;

recurrencePattern.NoEndDate = false;

recurrencePattern.StartTime = System.DateTime.Now.AddMinutes(10);

recurrencePattern.PatternStartDate = System.DateTime.Now.AddDays(14);

recurrencePattern.PatternEndDate = System.DateTime.Now.AddYears(1);

recurrencePattern.Dispose();

 

appointment.Links.NewLink().SetLinkFromString(refLink);

appointment.ClearRecurrencePattern();

 

appointment.Save();

appointment.Display();

 

appointment.Dispose();