Das Notes Forum

Domino 9 und frühere Versionen => ND8: Entwicklung => Thema gestartet von: Scotty67 am 02.12.11 - 13:55:49

Titel: Body Feld von einem Dok in ein neues Dok in einer anderen DB kopieren
Beitrag 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
Titel: Re: Body Feld von einem Dok in ein neues Dok in einer anderen DB kopieren
Beitrag von: Peter Klett am 02.12.11 - 13:59:07
Klar, wenn Du BodyA setzt und dann BodyB kopierst ...
Titel: Re: Body Feld von einem Dok in ein neues Dok in einer anderen DB kopieren
Beitrag von: koehlerbv am 02.12.11 - 13:59:39
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.
Titel: Re: Body Feld von einem Dok in ein neues Dok in einer anderen DB kopieren
Beitrag von: Scotty67 am 02.12.11 - 14:22:17
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")"
Titel: Re: Body Feld von einem Dok in ein neues Dok in einer anderen DB kopieren
Beitrag von: koehlerbv am 02.12.11 - 14:25:44
ich bekomm die fehlermeldung "object variable not set" bie  "all BodyA.CopyItemToDocument(newdoc, "Body")"

Ab ins Wochenende, Hannes  ;)

Bernhard
Titel: Re: Body Feld von einem Dok in ein neues Dok in einer anderen DB kopieren
Beitrag von: Scotty67 am 02.12.11 - 14:42:17
@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")
Titel: Re: Body Feld von einem Dok in ein neues Dok in einer anderen DB kopieren
Beitrag von: koehlerbv am 02.12.11 - 15:04:03
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