Reg Exp
Web Design
Notes Client
Determine If A Private View Is Out Of Date
When dealing with shared, private on first use views, the biggest problem is that the design of the private view will not change once it is first built. The way to deal with this problem is to delete and recreate the private view. This script will determine if the design of the private view is out of date and delete the private view so it can be recreated.

Sub Initialize
   Dim s As New notesSession
   Dim db As notesDatabase
   Dim view As notesView
   Dim viewNote As notesDocument
   Dim flags As Variant
   Dim removeIt As Integer
   Set db = s.currentDatabase
   Set view = db.getView("<<ENTER VIEW NAME HERE>>")
   removeIt = False
   If Not view Is Nothing Then
      Set viewNote = db.getDocumentByUNID(view.universalID)
      flags = viewNote.getItemValue("$Flags")
      If Isarray(flags) Then
         If Instr(flags(0), "V") <> 0 Then
            Forall indView In db.views
               If indView.name = view.name And indView.universalID <> view.universalID Then
                  If indView.lastModified > view.created Then removeIt = True
               End If ' Ends the check to see if we found the orignal (not private) view
            End Forall ' Loop through all the views in the database
         End If ' Ends the check to see if the view is a private view
      End If ' Ends the check to see if the view note has a $Flags item
   End If ' Ends the check to make sure the view was found
   If removeIt Then
      flags = "The design of the private view " & view.name & " was out of date. The view"
      flags = flags & " has been deleted from your system. You should exit the database"
      flags = flags & " and re-enter to re-build the view with the correct design."
      Call view.remove()
      Msgbox flags, 16, "View Out Of Date"
   End If
End Sub

When the "getView" method is called, the private view will always be returned (if there is a private view). Private views always have a value of "V" in the $Flags item in the design element. Checking for that assures that the private view was returned (otherwise, the user hasn't opened the shared view to build the private view). Once the private view is found, all the views in the database are searched to find the shared view (the one that has the same name but a different UNID). Once the shared view is found, the date the shared view was last modified is compared to the date the private view was created. If the shared view was last modified more recently, the private view is out of date and flagged for deletion.

At the bottom of the loop, if the private view needs to be deleted, it is deleted and a message is shown to the user. The user will need to exit out of the database for the list of views to be refreshed. Otherwise, the client will think that the private view still exists and attempt to open that. Exiting out of the database clears that cache.