With this Lotus Notes agent, you'll be able to update a specific field in all selected Lotus Notes documents with new data.
'Declarations: Dim session As NotesSession Dim ws As NotesUIWorkSpace Dim db As NotesDatabase Dim dc As NotesDocumentCollection Dim doc As NotesDocument Dim FieldName As String, NewValue As String, Message As String Dim item As NotesItem Dim YesNo As Variant Dim i As Integer 'Initilaize: Sub Initialize Dim session As New NotesSession Set ws = New NotesUIWorkSpace Set db = session.CurrentDatabase Set dc = db.UnprocessedDocuments Set doc = dc.GetFirstDocument FieldName = Inputbox$("Enter Field Name. Enter this value very carefully. Spelling counts.","Enter Field") If FieldName = "" Then Exit Sub NewValue = Inputbox$("Enter the new value. Enter 'Quit' to abort.","Enter Value") If NewValue = "Quit" Then Exit Sub Message = "Field Name: " & FieldName & Chr$(13) & _ "New Value: " & NewValue & Chr$(13) & _ "Records to be Updated: " & Cstr(dc.Count) & Chr$(13) & Chr$(13) &_ "Do you wish to continue?" YesNo = Messagebox(Message,36,"Continue?") If YesNo = 7 Then Exit Sub For i = 1 To dc.Count Set doc = dc.GetNthDocument(i) Set item = doc.ReplaceItemValue(FieldName,NewValue) Call doc.Save(True, True) Next End Sub
This tip is overly complex. It ignores a simpler, method already available in the documentcollection class.
Don't forget that the NotesDocumentCollection.GetNthDocument gets extremely slow when the number of documents in the NotesDocumentCollection is large.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip library by member Mick Crowder. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.