Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Set db = session.CurrentDatabase
Set view = db.GetView("All")
Messagebox view.TopLevelEntryCount,, "Before new doc"
Dim doc As New NotesDocument(db)
Call doc.ReplaceItemValue("Form", "Main Topic")
Call doc.ReplaceItemValue("Subject", "New document")
Call doc.Save(True, True)
Messagebox view.TopLevelEntryCount,, _
"After new doc, before refresh"
Call view.Refresh
Messagebox view.TopLevelEntryCount,, _
"After new doc, after refresh"
End Sub
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim newDoc As NotesDocument
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView( "By Category" )
' create a new document with Latest news category
Set newDoc = New NotesDocument( db )
newDoc.Form = "Main Topic"
newDoc.Categories = "Latest news"
newDoc.Subject = "Just created this doc"
Call newDoc.Save( True, True )
' try to get first document in Latest news category
Set doc = view.GetDocumentByKey( "Latest news" )
' even though doc is saved, it doesn't appear in view yet
If ( doc Is Nothing ) Then
Messagebox( "Refresh the view" )
End If
Call view.Refresh
' after refresh, try again
Set doc = view.GetDocumentByKey( "Latest news" )
If ( doc Is Nothing ) Then
Messagebox( "Something's wrong" )
Else
Messagebox( "Now that view is refreshed, doc appears" )
End If
End Sub