This code will show how to rebuild views using a scheduled Lotus Domino agent. This is helpful when we use @TextToNumber(today) in a view's column formula when the view requires a rebuild every day , and refreshing the view will not serve the purpose or reflect the correct value.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim col As NotesViewColumn
Dim i As Integer
Dim RView As String
On Error Resume Next
Set db = session.CurrentDatabase
' List of views which u wants to rebuild
Dim Rviews() As String
Redim Rviews(0 To 2)
Rviews(0)=("ABC")
Rviews(1)=("EFG")
Rviews(2)=("XYZ")
' a temporary change in design of views needs to be made in order to rebuild a view
' we are doing it by adding a temporary Column and deleting it back.
i=0
While i<=Ubound(Rviews)
Set view = db.GetView(Rviews(i))
Set col = view.CreateColumn(view.ColumnCount + 1, "Test","OrderNo")
Call view.Refresh
Set col = view.Columns(view.ColumnCount - 1)
Call view.RemoveColumn(view.ColumnCount)
Call view.Refresh
Print "View -" & i
i=i+1
Wend
End Sub
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip library by member Huzefa Amar Haider. Please let others know how useful it is via the rating scale at the end of the tip. 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.