A computed-for-display field with the following formula will act as a counter for Notes and web access with a timestamp and keeping the counter by document id fields within a single profile document:
profilename := "Page Usage Count"; docid := @Text(@DocumentUniqueID); timestamp := @Now; count := @GetProfileField(profilename; "Count"+docid); @If(count=""; @Do(@Set("count";1); @SetProfileField(profilename; "TimeStamp"+docid; timestamp)); @Do(@Set("timestamp";@GetProfileField(profilename; "TimeStamp"+docid)); @Set("count"; count+1))); @SetProfileField(profilename; "Count"+docid; count); "This page has been accessed " + @Text(count) + " times since " + @Text(timestamp; "D0T1S2")
Create an agent using this code:
Sub Initialize Dim Session As New NotesSession Dim ProfileDoc As NotesDocument Dim doc As NotesDocument Dim num As Double Dim NumStr As String
Set db = Session.CurrentDatabase
'The following line gets a handle to the current document Set doc = Session.DocumentContext
'The following line creates a Profile document called 'Domino' the first time 'it is executed and from then on modifies the existing 'Domino' document Set ProfileDoc = db.GetProfileDocument("Domino")
NumStr = ProfileDoc.num(0) If NumStr = "" Then num = 1 Else num = Cdbl(NumStr) + 1 End If
ProfileDoc.num = Cstr(num) Call profiledoc.save(False,False)
doc.Number = num
Make the agent Shared and select "Run Once (@commands may be used)" for the option "Which document(s) should it act on". Name it whatever you desire (for example: "Counter") and save. Please be aware that Notes has a limit on the number of fields you can have in a form, so you cannot have an infinite number of these counters.
On the form you wish to keep the counter on, create a number field named Number. Also add a computed text field named $$QueryOpenAgent. As the formula for this field, put in quotes whatever you named your agent (for example: "Counter").