Domino Code Fragment

Code Name*
Displaying Domino hit Counter Values in Profile DocumentsAuthor
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.191.135.224
Description*
The profile documents are a new feature requiring Notes 4.5 to use, set, display, etc. There is no way I know of to select profile documents for use in a view. However, it was fairly simple to write an agent that displays all the counter fields in a profile doc ument. The agent can also be used from the web. Here is the sample agent I have been using (long lines wrapped and you must "unwrap" them to try the agent:
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

Sub Initialize
'This can be run from the web via the URL /dbname/Display+Profile?OpenAgent
Dim Session As New NotesSession
Dim ProfileDoc As NotesDocument
Dim profilename As String
Dim webrun As Variant


Dim itemname As String
Dim itemvalues As Variant
Dim itemvaluecount As Integer
Dim docid As String
Dim docidlink As String
Dim dateitem As notesitem
Dim dateval As notesdatetime
Dim datemod As Variant
Dim datecreate As Variant
Dim doc As notesdocument
Dim br As String


Profilename = "Page Usage Count" ' use a variable for profile name so debug can change it
Set db = Session.CurrentDatabase
Set doc = session.documentcontext
If doc Is Nothing Then webrun = False Else webrun = True ' If there is a context document, then we are executing from the web
If webrun Then br = "<br>" Else br = ""


'The following line accesses a Profile document and then we display counters from it
Set ProfileDoc = db.GetProfileDocument(Profilename)


datemod = profiledoc.lastmodified
datecreate = profiledoc.created
Print profilename & " profile document was created on " & Format$(datecreate,"General Date") _
& " & last modified on " Format$(datemod,"General Date") & br


Forall i In profiledoc.items
itemname = i.name
If Left$(itemname, 5) = "Count" Then
docid = Mid$(itemname, 6)
Set dateitem = profiledoc.getfirstitem("TimeStamp" & docid)
Set dateval = dateitem.datetimevalue
If webrun Then
docidlink = |<A href="all+by+date/| & docid & |?opendocument">Document | & docid & |</A>|
Else
docidlink = |Document | & docid
End If
Print "Counter for " & docidlink & " is " i.values(0) " since " & dateval.localtime & br


Elseif itemname="$UpdatedBy" Then
itemvaluecount = Ubound(i.values) +1
Print |"$UpdatedBy" field is | & itemvaluecount & | entries with a total length of | & i.valuelength & | bytes| & br
If itemvaluecount >=3 Then
Print " The last 3 entries are: " & i.values(itemvaluecount-3) & ", " & i.values(itemvaluecount-2) & " and " & i.values(itemvaluecount-1) & br
End If
End If
If itemname="$Revisions" Then
itemvaluecount = Ubound(i.values) +1
Print |"$Revisions" field is | & itemvaluecount & | entries with a total length of | & i.valuelength & | bytes| & br
End If
End Forall


End Sub