Das Notes Forum
Domino 9 und frühere Versionen => ND8: Entwicklung => Thema gestartet von: Scotty67 am 02.12.11 - 13:55:49
-
Ich möchte mit selktierten Dokumenten einen Agent starten der aus den selektierten Dokumenten ein paar Informationen rausholt - auch das Body Feld - und diese dann in ein neues Dokument kopiert und speichert.
So wie's da unten steht funkt es nicht.
Danke für eure Vorschläge
lg/hannes
**********************
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim newdb As NotesDatabase
Dim doc As NotesDocument
Dim newdoc As NotesDocument
Dim RechnerName As variant
Dim SystemName As Variant
Dim Kunde As Variant
Dim Ort As Variant
Dim RVCreator As Variant
Dim RVCreationDate As Variant
Dim neuerBetreff As String
Dim RVNrView As NotesView
Dim RVDoc As NotesDocument
Dim RVNR As NotesItem
Dim BodyA As NotesItem
Dim BodyB As NotesItem
Dim LetzteRVNummer As Variant
Dim RAll As NotesItem
Dim Status As NotesItem
Dim FormType As NotesItem
Set db = session.CurrentDatabase
Set newdb = New NotesDatabase( "APPL01.AT.ABB.COM/SRV/ABB", "GLOBAL\ATABB\ATABB174.NSF" )
'Set newdb = New NotesDatabase( "", "GLOBAL\ATABB\ATABB174.NSF" )
Dim collection As NotesDocumentCollection
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument
'Set newdoc = newdb.CreateDocument
newdoc.Form = "RV"
Set newdoc = New NotesDocument(newdb)
'newdoc.Form = "RV"
If (Not collection Is Nothing) Then
RechnerName = doc.GetItemValue( "_RV_Hostname" )
SystemName = doc.GetItemValue("_NLDocSubject")
Kunde = doc.getItemValue("_NL_Kunde")
Ort = doc.getitemvalue("_NL_Anlage")
RVCreator=doc.Getitemvalue("RV_Creator")
RVCreationDate=doc.GetItemValue("RV_CreationDate")
Set BodyA = doc.GetFirstItem("Body")
neuerBetreff =RechnerName(0) + " - " + SystemName(0)
newdoc.DocSubject = neuerBetreff
newdoc.Kunde=Kunde
newdoc.Ort=Ort
newdoc.DocAuthor=RVCreator
newdoc.DocCreationDate=RVCreationDate
Call BodyB.CopyItemToDocument(newdoc, "Body")
' ######### RV Nummer Ermittlung START ############
Set RVNrView = newdb.GetView( "RVLfdNr")
Set RVDoc = RVNrView.GetLastDocument
LetzteRVNummer = RVDoc.GetItemValue( "RVNummer" )
LetzteRVNummer(0)=LetzteRVNummer(0)+1
Set RVNR = newdoc.ReplaceItemValue( "RVNummer", CStr(LetzteRVNummer(0)))
Set RAll = newdoc.ReplaceItemValue("DocReaders","$ATABB_174_Editors")
Set Status = newdoc.ReplaceItemValue("DocStatus","0")
Set FormType = newdoc.ReplaceItemValue("FormType","RV")
' ######### RV Nummer Ermittlung END ############
Call newdoc.Save( True, True )
'Set newdoc = newdb.CreateDocument
Set doc = collection.GetNextDocument(doc)
End If
End Sub
-
Klar, wenn Du BodyA setzt und dann BodyB kopierst ...
-
Sollen wir uns jetzt den Code durchlesen, ohne zu wissen, *was* nicht funktioniert, Hannes?
Bernhard
PS: Was ich aber vorab schon mal sehe: BodyB setzt Du nicht, da setzt es eine saubere Fehlermeldung.
-
mensch, mein fehler
soll natürlich
Call BodyA.CopyItemToDocument(newdoc, "Body")
lauten, ich bekomm die fehlermeldung "object variable not set" bie "all BodyA.CopyItemToDocument(newdoc, "Body")"
-
ich bekomm die fehlermeldung "object variable not set" bie "all BodyA.CopyItemToDocument(newdoc, "Body")"
Ab ins Wochenende, Hannes ;)
Bernhard
-
@Bernhard ! a bissi später ;D
vorher hätte ich das gerne noch hinbekommen
Das "newdoc" inkl. Form wird ja von mir vorgegeben.
Set newdoc = New NotesDocument(newdb)
newdoc.Form = "RV"
somit hole ich mir ja ds Body Feld vom alten Dokument
Set BodyA = doc.GetFirstItem("Body")
warum schmeckt dem LN das hier nicht ?
Call BodyA.CopyItemToDocument(newdoc, "Body")
-
Nur nicht zuviele Informationen, Hannes ... ;)
Hast Du das Vorhandensein von bodyA geprüft? Welche Fehlermeldung kommt? Ist es wirklich diese Zeile? Passiert das bei jedem Dokument (was mit meiner ersten Frage zusammenhängt).
Bernhard