Tuesday, June 19, 2012

Finding unused views

I recently talked about identifying the views used by users. The bigger challenge is to find those views used programmatically. And, knowing what views are used by users doesn't really help get rid of views because you need a list of all the views in a database. This turns out to be very easy to get - all you need to do is use the NoteCollection class. Here is the relevant code to create a document for every view in a database.


Set nnc = db.CreateNoteCollection( False ) nnc.Selectviews = True Call nnc.BuildCollection If nnc.count > 0 Then noteID = nnc.GetFirstNoteId For x = 1 To nnc.Count Set doc = db.Getdocumentbyid( Noteid ) ' create doc for each element Set newDoc = thisDB.Createdocument() newDoc.Form = "Views" If doc.Hasitem("$Title" ) Then set typestring = doc.Getfirstitem("$Title" ) If InStr( typestring.text, "|" ) Then newDoc.Viewname = Left( typestring.text, InStr( typestring.text, "|" )-1 ) newDoc.Alias = Right( typestring.text, Len( typestring.text) - InStr( typestring.text, "|" ) ) Else newDoc.ViewName = typeString.Text End If End if newDoc.elementNoteID = noteID Call newdoc.Save(True, True ) noteID = nnc.Getnextnoteid( Noteid ) Next End if





This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.

Once you have the list of views, you can now combine this with the list of views used or look in related databases to see who calls the view.  This last part is also very trivial if you use a tool like Teamstudio's Configurator to search all design elements for the view name and aliases.

Let me know if you are interested in this bit as well.

No comments:

Post a Comment