ToDo Objekt

Hinweis: Wenn man die Datumswerte auf einen ungültigen Wert setzt (hier 0), so wird automatisch 31.12.1900 0 Uhr eingetragen.

Wenn man die Werte NICHT setzt, so wird das heutige Datum genommen.

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 oToDo : Set oToDo = cRM.CurrentProject.timemanager.ToDos.Add()

 

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

oToDo.ActionID = "TMMAIL"

oToDo.ActionType = "1"

oToDo.Attendees.Add("LFrisch")

oToDo.Attendees.Add("THeld")

oToDo.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 der \ul Aufgabe\ulnone\par}"

' oToDo.BodyPlain = "Inhalt/Text des Termins ohne RTF-Formatierung"

oToDo.Categories.Add("Meeting")

oToDo.ChangeDate = Now()

oToDo.ChangeUser = sCurrentUserLoginName

oToDo.Contact = "Kontakt, mit dem die Aufgabe stattfindet"

oToDo.CreationDate = Now()

oToDo.CreationUser = sCurrentUserLoginName

oToDo.End = DateAdd("h", 2, Now())

oToDo.ExtUserData1 = "Erster Abschnitt von Zusatzinformationen"

oToDo.ExtUserData2 = "Zweiter Abschnitt von Zusatzinformationen"

oToDo.HostDataBase = sRefLink

oToDo.Importance = 3

oToDo.Private = False

oToDo.Reminder = True

oToDo.ReminderMinutesBeforeStart = 30

oToDo.Start = DateAdd("h", 1, Now())

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

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

oToDo.User = sCurrentUserLoginName

 

Dim sUniqueID : sUniqueID = oToDo.UniqueID

Call oToDo.Links.NewLink.SetLinkFromString(sRefLink)

 

Call oToDo.Save()

Call oToDo.ExportAsICal("C:\" & sRecordRefDescription & ".ical")

Call oToDo.Display()

Call oToDo.Remove()

 

Set oToDo = Nothing

Beispiel C#-Script:

Project project = cRM.CurrentProject;

View activeView = project.ActiveViews.ActiveView;

ViewConfig viewConfig = activeView.Config;

Record record = activeView.CurrentRecordSet.CurrentRecord;

string currentUserLoginName = project.Users.CurrentUser.LoginName;

string primaryKeyFieldName = viewConfig.PrimaryKeyFldName;

string recordRefDescription = record.GetRecordRefDescription();

string refLink = project.ID + "|" + activeView.Name + "|" + viewConfig.FamilyName + "|" + primaryKeyFieldName + "|" + record.GetContentsByName(primaryKeyFieldName) + "|" + recordRefDescription;

record.Dispose();

viewConfig.Dispose();

activeView.Dispose();

project.Dispose();

 

ToDo todo = cRM.CurrentProject.TimeManager.ToDos.Add();

 

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

todo.ActionID = "TMMAIL";

todo.ActionType = "1";

todo.Attendees.Add("LFrisch");

todo.Attendees.Add("THeld");

todo.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 der \ul Aufgabe\ulnone\par}";

// todo.BodyPlain = "Inhalt/Text des Termins ohne RTF-Formatierung"

todo.Categories.Add("Meeting");

todo.ChangeDate = System.DateTime.Now;

todo.ChangeUser = currentUserLoginName;

todo.Contact = "Kontakt, mit dem die Aufgabe stattfindet";

todo.CreationDate = System.DateTime.Now;

todo.CreationUser = currentUserLoginName;

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

todo.ExtUserData1 = "Erster Abschnitt von Zusatzinformationen";

todo.ExtUserData2 = "Zweiter Abschnitt von Zusatzinformationen";

todo.HostDatabase = refLink;

todo.Importance = 3;

todo.Private = false;

todo.Reminder = true;

todo.ReminderMinutesBeforeStart = 30;

todo.Start = System.DateTime.Now;

todo.Subject = "Priorität" + todo.Importance.ToString() + ": Meeting im Büro mit " + recordRefDescription;

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

todo.User = currentUserLoginName;

 

string uniqueID = todo.UniqueID;

todo.Links.NewLink.SetLinkFromString(refLink);

 

todo.Save();

todo.ExportAsiCal(@"C:\" + recordRefDescription + ".ical");

todo.Display();

todo.Remove();

 

todo.Dispose();