Hallo an Alle,
hab da mal wieder nen Problem ;)
Folgends. Durch einen Button werden 3 Agenten aufgerufen (theoretisch nacheinander was auch gemacht wird)
Button in Dokument A (DocA)
--> Aktuelles Dokument wir Gespeichert (DocA)
--> 1. Agent erstellt Dokument B (DocB)
--> Aktuelles Dokument wir Gespeichert (DocB)
--> 2. Agent erstellt Dokument C (DocC)
--> 3. Agent füht diverses aus. (siehe Unten)
3.Agent:
Es werden in allen 3 Dokumenten verschiedene Felder gesetzt,
dann möchte ich das DokA und DokB ins Frontend holen, speichern und schließen
CODE:
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
REM Standard
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Dim DL As NotesDocument
Dim AU As NotesDocument
Dim AUDB As NotesDatabase
Set AUDB = session.GetDatabase(db.Server,[SERVER], [DB] )
Set DL = AUDB.GetDocumentByUNID(doc.GARefUNID(0))
Set AU = AUDB.GetDocumentByUNID(DL.AufDocUNID(0))
Set uidoc = workspace.EditDocument(True,AU,,,,False)
Call uidoc2.Save
Call uidoc2.Close
Set uidoc = workspace.EditDocument(True,DL,False,,True,False)
Call uidoc.Save
Call uidoc.Close
Anmerkung: Ich habe 2 verschiedene EditDocument in diesem odeauszug um zu zeigen das ich mit den Attributen schon ausprobiert bzw. geschaut haben das diese passen.
Bei drücken des Buttons klappt alles soweit bis man zu der Zeile mit dem Set UIDoc kommt. Dort kommt der Fehler
"Ungültiges oder nicht vorhandenes DOkument"
Fehlernummer: 4412
Ich hoffe ich habe nichts zu wichtiges vergessen undhoffe das Ihr mir helfen könnt.
Vielen Dank schonmal.
@Bernhard,
Warum das 3 Agenten machen, folgendes: Die anderen beiden Agenten die ausgeführt werden sind durch fremdfirma erstellte Agenten an die ich möglichst wenig bzw. gar nicht dran rumfummeln will.
@Dau-In
ich habe mir in nem Print für DL und AU jewils die DOCUNIDS ausgeben lassen und die erscheinen auch i der ausgabe. und das Doc ist deklariert nur wieder vergessen hatte gestern irgendwie Keinen plan mit gar nichts mehr.
Anbei ein neuer Code indem jetzt hoffentlcih nichts fehlt.
[BUTTON]
@Command([FileSave]);
@Command([RunAgent];"[AGENT1]"); REM {Dieser erstellt DocB};
@Command([FileSave]);
@Command([RunAgent];"[AGENT2]");REM {Dieser erstellt DocC};
@PostedCommand([RunAgent];"[AGENT3]");REM {Dieser ändert die Felder siehe unten};
[AGENT3]
Sub Initialize
On Error Goto ERRORSTEP
Print "ZUSATZAGENT"
REM Umgebung
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
REM Standard
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
Dim DL As NotesDocument
Dim AU As NotesDocument
Dim AUDB As NotesDatabase
Set AUDB = session.GetDatabase(db.Server,[DB])
Set DL = AUDB.GetDocumentByUNID(doc.GARefUNID(0))
Print "DL = " + Cstr(DL.UniversalID) 'hier erscheint auch wirklich ne DOCUNID
Set AU = AUDB.GetDocumentByUNID(DL.AufDocUNID(0))
Print "AU = " + Cstr(AU.UniversalID) 'hier erscheint auch wirklich ne DOCUNID
AU.XX_EBDocUNID = DL.EBDocUNID(0)
doc.XX_AufDocUNID = DL.AufDocUNID(0)
doc.XX_FELD1 = Cstr(session.CommonUserName)
doc.XX_FELD2 = "[TEXT]"
doc.XX_FELD3 = "[TEXT]"
doc.AAName = AU.AufName(0)
doc.AANr = AU.AufNr(0)
doc.AADocUNID = AU.AufDocUNID(0)
If AU.LNR(0) <> "" Then
DL.LNR = AU.LNR(0)
doc.LNR = AU.LNR(0)
Else
Dim Profil As NotesDocument
Set Profil = db.GetProfileDocument("[MASKE]")
If Profil Is Nothing Then
Messagebox "Profildokument nicht gefunden --> Abbruch"
Else
Dim LNRS As String
LNRS = Profil.X_JZ(0) + Profil.X_JZT(0) + Cstr(Profil.X_LNR(0))
doc.LNR = LNRS
DL.LNR = LNRS
AU.LNR = LNRS
Profil.X_LNR = Profil.X_LNR(0) + 1
Call Profil.Save(True,False)
End If
End If
Print "AU2 = " + Cstr(AU.UniversalID) 'hier erscheint auch wirklich ne DOCUNID
Set uidoc = workspace.EditDocument(True,AU,,,,False) '<--------- HIER IST DER FEHLER bzw. HIER KOMMT DIE MELDUNG
Call uidoc.Save
Call uidoc.Close
Print "DL2 = " + Cstr(DL.UniversalID)
Set uidoc = workspace.EditDocument(True,DL,False,,True,False)
Call uidoc.Save
Call uidoc.Close
Set uidoc = workspace.EditDocument(True,doc,False,"","",False)
Call uidoc.Save
Exit Sub
ERRORSTEP:
Const Teilbereich = ""
Msgbox "Es ist ein Fehler aufgetreten." & Chr(10) & Chr(10) _
& "Teilbereich: " & Teilbereich & Chr(10) _
& "Fehlermeldung: " & Error$ & Chr(10) _
& "Fehlernummer: " & Err & Chr(10) _
& "Codezeile: " & Erl & Chr(10) _
,64,"Error"
Print "Teilbereich: " & Teilbereich & " - " & Cstr(Error$) & " - Nr: " & Cstr(Err) & " - Zeile: " & Cstr(Erl)
Exit Sub
End Sub
So dies ist eigentlcih der exakt kopierte COde aus meinem Agenten
Hoffe euch fällt was ein.