Hi @all,
Ich habe mir ein script geschrieben , mit dem ich mir alle Dokumente mit gewissen
Definitionen aus einer View filtere und jeden gefundene Dokument kopiere.
Danach soll das Dokument bearbeitet werden.
Zum Schluss möchte ich ein Item löschen und es neu erzeugen lassen.
Hier erstmal der Code:
| Option Public |
| Sub Initialize |
| |
| ' Dim ws As New NotesUIWorkspace |
| Dim session As New NotesSession |
| Dim docThis As NotesDocument |
| Dim db As NotesDatabase |
| Dim view As NotesView |
| Dim doc As NotesDocument |
| Dim doc2 As NotesDocument |
| Dim nav As NotesViewNavigator |
| Dim counter As Long |
| Dim actcounter As Long |
| Dim x As Variant |
| Dim y As Variant |
| Dim z As Variant |
| Dim success As Variant |
| |
| |
| Set db = session.CurrentDatabase |
| Set view = db.GetView( "Serien-Geräte" ) |
| Call view.Refresh |
| REM Create navigator for entire view and get count |
| Set nav = view.CreateViewNav() |
| 'Messagebox nav.Count,, "Number of entries in view" |
| actcounter = nav.Count |
| counter= 0 |
| If Not view Is Nothing Then |
| Set doc = View.GetFirstDocument() |
| While Not doc Is Nothing |
| |
| Set oDocnext = View.GetNextDocument(Doc) |
| |
| y =Doc.GetItemValue("form")(0) |
| z= Doc.GetItemValue("Hide_kategorie")(0) |
| x= Doc.GetItemValue("Serie")(0) |
| counter= counter +1 |
| |
| If y ="dokument_kopf" And z= "Serien-Geräte" Then |
| If x = "2011" Then |
| |
| counter = counter + 1 |
| Set doc2 = doc.Copytodatabase(db) |
| |
| Dim oldtitel As String |
| oldtitel =Doc.GetItemValue("titel")(0) |
| oldtitel = Left$(oldtitel, Len(oldtitel)-4) |
| doc2.titel = oldtitel + "2012" |
| doc2.Serie= "2012" |
| Call doc2.Removeitem("ID_MainDOC") |
| success = doc2.ComputeWithForm( False, False ) |
| If success Then |
| Call doc2.Save( True, True ) |
| End If |
| End If |
| End If |
| |
| If counter =actcounter Then |
| Exit Sub |
| End If |
| Set Doc=oDocnext |
| Wend |
| End If |
| End Sub |
Nun scheint es so das manchmal das Item "ID_MainDOC" durch den Befehl "ComputeWithForm" nicht
angelegt wird.
Wie kann ich sicherstellen das hier immer das Dokument erst dann gespeichert wird,
wenn das Feld vorhanden und mit der DocID gefüllt wurde.
Danke schon mal vorab.....
Gruß Jörg