Examples: IsSorted property (NotesViewColumn - LotusScript®)
- This agent checks if the first column in the By Author view of
the current database is sorted.
Sub Initialize Dim session As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim column As NotesViewColumn Set db = session.CurrentDatabase Set view = db.GetView( "By Author" ) Set column = view.Columns( 0 ) If column.IsSorted Then Messagebox( "The first column is sorted." ) Else Messagebox( "The first column is unsorted." ) End If End Sub
- This agent toggles whether the first column is sorted.
Sub Initialize Dim session As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim vc As NotesViewColumn Set db = session.CurrentDatabase Set view = db.GetView("View A") Set vc = view.Columns(0) vc.IsSorted = NOT vc.IsSorted End Sub
- This agent finds the documents in a view that match the key "Blowfish"
and puts them into a folder.
- The GetDocumentByKey method finds the first document in the view that matches "Blowfish."
- To find subsequent matching documents, the script loops through the remaining documents in the view. It keeps looping as long as the document matches the key. To match the key, the document's column value for the first sorted and categorized column in the view must equal "Blowfish."
Why doesn't the script look for documents where doc.ColumnValues(0) = "Blowfish"? Because the first column in the view may or may not be the first sorted and categorized column in the view. Therefore, the script uses the IsSorted property to find the first sorted and categorized column in the view and uses column.Position - 1 to get the correct column value from the document.
Sub Initialize Dim db As New NotesDatabase( "", "ocean.nsf" ) Dim view As NotesView Dim column As NotesViewColumn Dim doc As NotesDocument Dim done As Variant Set view = db.GetView( "By Category" ) ' get the first sorted and categorized column in the view Forall c In view.Columns If ( c.IsSorted And c.IsCategory ) Then Set column = c Exit Forall End If End Forall ' get the first document that matches the key Set doc = view.GetDocumentByKey( "Blowfish" ) ' get the remaining documents that match the key ' since ColumnValues array starts at 0 for position 1, ' subtract 1 from the column position While ( doc.ColumnValues( column.Position - 1 ) _ = "Blowfish" ) Call doc.PutInFolder( "Fishy" ) Set doc = view.GetNextDocument( doc ) Wend End Sub