I’m trying to search for a document in a view based on a key that is supplied and then update certain fields. I’m good up until the part where I have to set Doc to something. I’m not sure what to do in order to be able to change the field I want.
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim view As NotesView
Dim item As NotesItem
Dim vc As NotesViewEntryCollection
Set db = session.CurrentDatabase
Set view = db.GetView(“My View Name”)
Set vc = view.GetAllEntriesByKey(“Key I’m Looking For”)
Set doc = “don’t know what to set it to”
Set item = doc.ReplaceItemValue(“Field Name”, Field Value)
Set item = doc.ReplaceItemValue(“Field Name 2”, Field Value 2)
Call doc.Save( True, True )
Thanks for all the help
Subject: Search For A Doc In A View Based On A Key & Change Field Values
Set vc = view.GetAllDocumentsByKey(“Key I’m Looking For”)
set doc = vc.getfirstdocument
while not doc is nothing
Set item = doc.ReplaceItemValue(“Field Name”, Field Value)
Set item = doc.ReplaceItemValue(“Field Name 2”, Field Value 2)
call doc.Save(true,true)
set doc = vc.getnextdocument(doc)
wend
Subject: RE: Search For A Doc In A View Based On A Key & Change Field Values
Thanks for all the help. I got it working using the code by G Matthys. However, I did have to change the type of vc from a NotesViewEntryCollection to a NotesDocumentCollection and this begin to work. Here is the modified code.
Thanks again for the help
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim view As NotesView
Dim item As NotesItem
Dim vc As NotesDocumentCollection
Set db = session.CurrentDatabase
Set view = db.GetView(“My View Name”)
Set vc = view.GetAllDocumentsByKey(“Key I’m Looking For”)
set doc = vc.getfirstdocument
while not doc is nothing
Set item = doc.ReplaceItemValue(“Field Name”, Field Value)
Set item = doc.ReplaceItemValue(“Field Name 2”, Field Value 2)
call doc.Save(true,true)
set doc = vc.getnextdocument(doc)
wend
Subject: Search For A Doc In A View Based On A Key & Change Field Values
Try:
doc.Field Name = “text string”
Paul.