Have you ever inherited an application that you did not build? It's big, slow, and for some reason there are 95...
views in it, many of which are named 'Copy of ...', 'Another Copy of ...' and 'zDeveloperView...' that you suspect are not being used any more. Would it be nice to know if the user population is still using a particular view? Getting rid of those extra, unused views can reduce the size of the database view index, helping your application's performance. Here is a simple method to determine if a view is being used, and how often.
Note: This method only counts user hits for users with a database access level of Editor or above, as Readers and below cannot edit the Profile Document.
Create a profile form. I will call it ViewHitProfileForm. Create a two-column table and enter all the view names and one field next to each view name that you need to track. The fields can be editable - text. Let us say we are tracking three views: View1Hits
Save the form.
Create an agent to edit the profile document.
Name: Edit ViewHitProfileForm
When should the agent run? Manually from Agent List
Which documents should it act on? Run once. (@Commands may be used)
Run Formula: @Command([EditProfile];"ViewHitProfileForm") Save the agent and run it to create and edit the profile document. You must enter a zero in each field or you will encounter errors. Save the newly created profile document.
Go to the design of each view and enter the following code in the PostOpen event:
@If(@TextToNumber(@Left(@UserAccess(@DbName);1)) < 3; Return(""); "");
Make sure to change the number on View1Hits to 2 and 3, depending on the view.
This code will retrieve the number of view hits from the profile document, increment it by one and then set it again in the profile document.
Any time you want to see how many hits the views have, simply run the agent and print the profile document. You can also reset the counters to zero to collect monthly or weekly statistics on view use. This can help focus future development efforts on the most heavily used views and also help you eliminate infrequently used views without guesswork.
If you need to track the last user of the view you could enter another field on the profile form called View1User. Then you could add the following code to record the username of the person who last accessed the view.