Examples: Refresh method
- This agent displays the top level entry count for an uncategorized
view three times: before creating a new doc that appears in the view,
after creating the document but before refreshing the view, and after
refreshing the view. The count is the same in the second display and
incremented in the last display.
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
- This agent creates a new document that appears in a categorized
view. The document is not accessible to any NotesView methods until
the Refresh method is called.
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