Hallo,
in einer Maske kann man ein Passwort eingeben, welches beim Speichern das HTTP-Passwort im Personendokument ändern soll.
Im Querysave der Maske wird ein Agent mit Call agent.RunOnServer(Cstr(gvBackenddoc.NoteID))
aufgerufen.
Der Code des Agenten ist unten aufgeführt.
Nun gehts los:
In der Serverkonsole wird ein "Gooooo" angezeigt, also doc gefunden.
Dann wird ein "Fehler13" in der Serverkonsole ausgegeben, also lief der Agent auf einen Fehler.
Zeile 13 ist diese: Set doc = db.GetDocumentByID(agent.ParameterDocID)
Das Personendokument im Adressbuch hat einen neuen Stempel (also gespeichert durch den Agenten), aber das neue Passwort funktioniert nicht.
Wenn ich den Code aus dem Agenten direkt in das Querysave werfe, läuft alles super.
1. Wisst ihr, warum der Agent meint, er hat einen Fehler in Zeile 13, obwohl er erst fehlerfrei über die Zeile läuft?
2. Wisst ihr vielleicht auch noch, warum das neue HTTP-Passwort per Agent nicht geht, aber aus dem Querysave direkt schon?
Ich brauche den Agenten, damit ich diesen mit dem Server signieren kann und der auf alle Personendokumente im Adressbuch Schreibrechte hat.
Vielen Dank für Hilfe!
Matthias
Sub Initialize
Dim db As notesdatabase
Dim s As New NotesSession
Dim doc As NotesDocument
' Dim coll As NotesDocumentCollection
On Error Goto fehler
'#######
Dim agent As notesagent
Set agent = s.CurrentAgent
Set db = s.CurrentDatabase
Set doc = db.GetDocumentByID(agent.ParameterDocID)
If doc Is Nothing Then
Print "################ FEHLER ################"
Else
Print "################ Gooooooooooooo ################"
End If
'#######
Dim tmp As Variant
Dim tmp2 As Variant
' Set coll = db.UnprocessedDocuments
' Set doc = coll.GetFirstDocument
Dim passwort As String
passwort = doc.passwort(0)
tmp = Evaluate({@Password("| & passwort & |" )}, doc)
Print passwort
'tmp2 = Evaluate(|@Password("wurst2010")|, doc)
Dim adressdoc As NotesDocument
Dim adressdocview As NotesView
Dim adressbuch As NotesDatabase
Set adressbuch = s.GetDatabase(db.Server, "names.nsf")
Set adressdocview = adressbuch.GetView("(Person Common)")
Set adressdoc = adressdocview.GetDocumentByKey(doc.user(0), True)
adressdoc.HTTPPassword = tmp(0)
Call adressdoc.ComputeWithForm(True, False)
Call adressdoc.Save(True, False)
' Call adressbuch.Replicate( "Sametime2" )
Exit Sub
fehler:
Print "Fehler" & Cstr(Erl)
Exit Sub
End Sub
In der Maske wird der Agent jetzt im Postsave aufgerufen.
Ich weiss nicht, ob ich gestern schon Wunschgedanken hatte, jedenfalls wirft der Agent immer noch einen Fehler. der Agent besteht mittlerweile nur noch aus:
Dim db As notesdatabase
Dim s As New NotesSession
Dim doc As NotesDocument
On Error Goto fehler
'#######
Dim agent As notesagent
Set agent = s.CurrentAgent
Set db = s.CurrentDatabase
Set doc = db.GetDocumentByID(agent.ParameterDocID)
Print doc.UniversalID
Print "####### 4 #########"
Exit Sub
Print "###### ENDE ########"
fehler:
Print "Fehler #" & Str(Err) & ": " & Error$ & " in Zeile " & Cstr(Erl)
Exit Sub
End Sub
und in der Serverkonsole steht
UniversalID
####### 4 #########
Fehler 4270 Invalid note id in Zeile 13
Wo ist mein Fehler?
Matthias
So läuft es jetzt ohne Fehler und das neue Passwort geht auch:
Sub Postsave(Source As Notesuidocument)
Dim db As NotesDatabase
Dim s As New NotesSession
Dim doc As NotesDocument
Set doc = source.Document
Set db = s.CurrentDatabase
Dim agent As NotesAgent
' nur replizieren, wenn es eine veränderung am passwort gab
If passwort_alt <> doc.passwort(0) Then
Set agent = db.GetAgent("ag_kennwort")
Call agent.RunOnServer(doc.NoteID)
End If
End Sub
und der Agent
Sub Initialize
Dim db As notesdatabase
Dim s As New NotesSession
Dim doc As NotesDocument
On Error Goto fehler
'#######
Dim agent As notesagent
Set agent = s.CurrentAgent
Set db = s.CurrentDatabase
Set doc = db.GetDocumentByID(agent.ParameterDocID)
If doc Is Nothing Then
Exit Sub
End If
Print doc.UniversalID
'#######
Dim passwort As String
passwort = doc.passwort(0)
Dim adressdoc As NotesDocument
Dim adressdocview As NotesView
Dim adressbuch As NotesDatabase
Set adressbuch = s.GetDatabase(db.Server, "names.nsf")
Set adressdocview = adressbuch.GetView("(Person Common)")
Set adressdoc = adressdocview.GetDocumentByKey(doc.user(0), True)
If adressdoc Is Nothing Then
Exit Sub
End If
adressdoc.HTTPPassword = passwort
Call adressdoc.Save(True, False)
' Call adressbuch.Replicate( "Sametime2" )
Print "##### FERTIG ####"
Exit Sub
fehler:
Print "Fehler #" & Str(Err) & ": " & Error$ & " in Zeile " & Cstr(Erl)
Exit Sub
End Sub
Ich glaube, mein Code in der Maske war nicht richtig. Ich hatte im Postsave noch den alten Code drin, wo ich das Dok noch mit Werten füllen wollte- im Postsave natürlich blödsinn.
Hätte ich mal den ganzen Code posten sollen ;D
Danke für eure Hllfe!
Matthias