I have some views that uses @UserName in the selection formula. For working that the view must be “Shared, Desktop Private on 1st use”. That is no problem.
But this views are be going to be redesigned quiet often.
As this is a bunch of views it is very uncomfortable for the user to delete each of this views to recreate from scratch with design changes.
I try different things to get that done with an agent but no one is fool-proof and give some strange results (sometimes even do not update the design).
Best result so far is to delete the icon from the workspace and open the application again. That works (until now) always. But this is so annoying for end users to reopen the app from the (deep leveled) server folders.
Any other method to update the design of “private on 1st use” views ?
'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.
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
Dim langue As String
Dim message As String
Dim titreMessage As String
langue = s.GetEnvironmentString("LangueBDInternet")
Set db = s.currentDatabase
'Obtenir la vue en fonction de la langue
If langue = "FR" Then
Set view = db.getView("DemndMesDemnd")
Else
Set view = db.getView("DemndMesDemndANG")
End If
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 Then 'Vue modèle trouvée
If indView.universalID <> view.universalID And indView.lastModified > view.created Then
' La vue n'est pas à jour, on la supprime et elle se recontruira à la prochaine ouverture
removeIt = True
End If
Exit Forall ' Vue modèle trouvée, inutile de continuer la boucle...
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
If langue = "FR" Then
titreMessage = "Mise à jour de vue"
message = "La structure de la vue privée " & view.name & " n'est pas à jour." &_
" La vue a été supprimée de votre système. Fermer et réouvrir la base " &_
" afin de reconstruire la vue avec la bonne structure."
Else
titreMessage = "View Out Of Date"
message = "The design of the private view " & view.name & " was out of date." &_
" The view has been deleted from your system. You should exit the database" &_
" and re-enter to re-build the view with the correct design."
End If
Call view.remove()
Msgbox message, 16, titreMessage
End If
'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.