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.

Wednesday, June 6, 2012

Gamification

Is simply a way to provide positive reinforcement to your users when they use your application the way you want them to.  Do you want them to click the Help button before calling you?  Do you want them to view the Open Actions view more often?  That's where gamification comes in.  The easiest way is to create a script library to handle your counting.  I also use per-user profile documents to track by user.  A simple subroutine would be like this


Sub counter( thing As String ) Dim s As New NotesSession Dim db As NotesDatabase Dim doc As NotesDocument Set db = s.CurrentDatabase Set doc = db.GetProfileDocument( "Counter", s.Username ) If Not( doc.HasItem( thing ) ) Then Call doc.Replaceitemvalue( thing, 1 ) Else Call doc.Replaceitemvalue( thing, doc.Getitemvalue( thing )( 0 ) + 1 ) End If Call doc.Save( True, True ) If ( CDbl( doc.Getitemvalue( thing )) Mod 100 ) = 0 Then MessageBox "Thanks for using " + thing + " for " + doc.GetItemValue( thing ) + " times", 48, "Congratulations" End If End Sub



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

Then, in the Click event or PostOpen event for the view (or form or whatever), simply use the script library and add a call to this routine, passing the name of the function (thing) that you want to track.  You can get real creative with this, extending the number of times before a second pop up or whatever.  You can also add in time periods - say for the last month.  It is very low overhead (compared to all the other extra code you might have inherited) and the profile documents are very efficient.

In a related manner, you can use this technique to find out what views users are using.  Simply pass in a view name and use a global profile document for all users.  This is a very powerful way to identify views that users aren't using anymore as candidates for deletion.  This works for user views.  Next post I will describe a technique to use for all those hidden views.

Sadly, this code needs to be added to every view, but I think the results are well worth the time.  I did this for an app with over 200 user views and was well on the way to removing a lot of them.  Maybe someone else has a technique for injecting this code in every view using DXML?