HCL Notes / Domino / Diverses > Entwicklung

Create recurring appointment

(1/1)

viktoriusrex:
Hello,
can somebody tell my, what is wrong here. I try to create a recurring appointment. It create something different(type is NOT Appointment) and if I select one created element it throws an error. "Falscher Datentyp für Operator oder @Funktion: Text erwartet"


--- Code: ---void Main()
{
var session = new NotesSessionClass();
session.Initialize("");
var mailFile = session.GetEnvironmentString("MailFile", true);
var server = session.GetEnvironmentString("MailServer", true);

NotesDatabase database = session.GetDatabase("", mailFile, false);
if(!database.IsOpen)
database.Open();

//Normal Meeting
NotesDocument document = database.CreateDocument();

UpdateAppointment(document, session);

//Repeating Meeting
DateTime appointmentStart = new DateTime(2020, 5, 13, 15, 0, 0);
DateTime appointmentEnd = new DateTime(2020, 5, 13, 16, 0, 0);

    List<DateTime> repeatStart = new List<DateTime>(){ appointmentStart, appointmentStart.AddDays(1), appointmentStart.AddDays(2), appointmentStart.AddDays(3) };
    List<DateTime> repeatEnd = new List<DateTime>(){ appointmentEnd, appointmentEnd.AddDays(1), appointmentEnd.AddDays(2), appointmentEnd.AddDays(3) };

document.ReplaceItemValue("Repeats", 1);
    document.ReplaceItemValue("OrgRepeat", 1);
    document.ReplaceItemValue("$CSFlags", "i");

    NotesDocument repeatingMaster = database.CreateDocument();
UpdateAppointment(repeatingMaster, session);
    repeatingMaster.ReplaceItemValue("Repeats", 1);
    repeatingMaster.ReplaceItemValue("OrgRepeat", 1);
    repeatingMaster.ReplaceItemValue("$CSFlags", "c");

    repeatingMaster.ReplaceItemValue("RepeatStartDate", appointmentStart);
    repeatingMaster.ReplaceItemValue("RepeatHow", "F");
    repeatingMaster.ReplaceItemValue("RepeatFor", 4);
    repeatingMaster.ReplaceItemValue("RepeatForUnit", "D");

    repeatingMaster.ReplaceItemValue("RepeatUnit", "D");
    repeatingMaster.ReplaceItemValue("RepeatInterval", 1);

    repeatingMaster.ReplaceItemValue("RepeatDates", repeatStart.ToArray());
    repeatingMaster.ReplaceItemValue("RepeatInstanceDates", repeatStart.ToArray());
    repeatingMaster.ReplaceItemValue("RepeatEndDates", repeatEnd.ToArray());
    repeatingMaster.ReplaceItemValue("RepeatUntil", repeatEnd.Last());

    repeatingMaster.ReplaceItemValue("StartDateTime", repeatStart.First());
    repeatingMaster.ReplaceItemValue("EndDateTime", repeatEnd.First());
    repeatingMaster.ReplaceItemValue("StartTimeZone", "Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZX=90$ZN=Romance");
    repeatingMaster.ReplaceItemValue("EndTimeZone", "Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZX=90$ZN=Romance");
    repeatingMaster.ReplaceItemValue("ApptUNID", repeatingMaster.UniversalID);

    repeatingMaster.ComputeWithForm(false, false);
    repeatingMaster.Save(true, false);

    document.ReplaceItemValue("CalendarDateTime", repeatStart.ToArray());
    document.ReplaceItemValue("StartDateTime", repeatStart.ToArray());
    document.ReplaceItemValue("EndDateTime", repeatEnd.ToArray());
    document.ReplaceItemValue("RepeatInstanceDates", repeatStart.ToArray());
    document.ReplaceItemValue("StartTimeZone", "Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZX=90$ZN=Romance");
    document.ReplaceItemValue("EndTimeZone", "Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZX=90$ZN=Romance");

    document.ReplaceItemValue("$Ref", repeatingMaster.UniversalID);
    document.ReplaceItemValue("$RefOptions", 1);
    document.ReplaceItemValue("ApptUNID", repeatingMaster.UniversalID);
   
    document.ComputeWithForm(false, false);
    document.Save(true, false);

}

void UpdateAppointment(NotesDocument document, NotesSession session)
{
document.ReplaceItemValue("Form", "Appointment");
    document.ReplaceItemValue("$CSVersion", 2);
document.ReplaceItemValue("Subject", "Subject");
document.ReplaceItemValue("Body", "Body");
    document.ReplaceItemValue("AppointmentType", 3);
   
    document.ReplaceItemValue("Chair", session.UserName);
    document.ReplaceItemValue("Principal", session.UserName);
    document.ReplaceItemValue("From", session.UserName);

    document.ReplaceItemValue("SequenceNum", 1);

    document.ReplaceItemValue("RequiredAttendees", "test@required.attendee");
    document.ReplaceItemValue("Location", "Location");
    document.ReplaceItemValue("$Alarm", 1);
    document.ReplaceItemValue("Alarms", 1);
    document.ReplaceItemValue("$AlarmOffset", -15);

document.ReplaceItemValue("$BusyName", session.UserName);
    document.ReplaceItemValue("$BusyPriority", 1);

    document.ReplaceItemValue("$PublicAccess", 1);
    document.ReplaceItemValue("Importance", 1);

    //document.ComputeWithForm(false, true);
//Output: Falscher Datentyp für Operator oder @Funktion: Text erwartet
//Was genau ist hier falsch?

document.ComputeWithForm(false, false);
    document.Save(true, false);
}

--- Ende Code ---

I tried already all ways to find an error but I am a newbie in Lotus Notes and there is not enough documentation or I can not find it

thank.

jBubbleBoy:
a description of the calendar document can be found here:
https://web.archive.org/web/20120905054315/http://www-12.lotus.com/ldd/doc/uafiles.nsf/docs/WPNotesCSSchema/$File/csschema.pdf

a description of the ComputeWithForm function can be found here:
https://help.hcltechsw.com/dom_designer/10.0.1/basic/H_COMPUTEWITHFORM_METHOD.html

or in other words, the error lies in the mask in a formula, which throws the error   

jBubbleBoy:
your code is very confusing  ;)

Tode:
Doppelpost bei Stackoverflow, wo ich ihm die selbe Antwort gegeben habe: Cal & Sched Schema und ComputeWithForm...

jBubbleBoy:
Gibt es bei Stackoverflow keine Doppelpost-Regel?

Da diese Frage immer wieder bei atnotes gestellt wird und jeder Notesentwickler irgendwann in diese Situation kommt, hier noch ein weiterer Lösungsansatz:
Man muss seinen Fall einfach im Notes-Kalender nachstellen, in diesem Fall mit 2 Dokumenten und bei wiederholenden Terminen mit Abhängigkeiten etc. würde ich noch einen Schritt weitergehen und zuerst eine Routine schreiben, welche aus den zuvor erstellten Beispielen doc.replaceItemValue(feld,wert) - Code erzeugt, und von dieser Basis ausgehend Felder ausschließen und mit eigenen Werten ersetzen und in Funktionen verpacken.

Die Code-Generierung hat mehrere Vorteile, zum einen sind 20-50 Zeilen Code, für die Codegenerierung, den 100-150 Zeilen Ergebniscode vorzuziehen und zum anderen werden Eingabefehler vermieden, die dem Fragesteller beim Lesen und Abtippen leider passiert sind, wahrscheinlich fehlen auch noch Felder ... in diesem Fall einen "Falscher Datentyp für Operator oder @Funktion: Text erwartet" zu beheben kann sehr Aufwendig sein, hier ist es hilfreich wenn man ein Tool besitzt, mit dem man Dokumente auf Unterschiede und Gemeinsamkeiten vergleichen kann.

Navigation

[0] Themen-Index

Zur normalen Ansicht wechseln