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
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?