Domino Code Fragment

Code Name*
Another Hit Counter Using Profile Documents
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.134.90.44
Description*
Doesn't create unique fieldnames for each document that you are counting (i.e. creates unique documents instead). Stores both the first access date and the last access date. Doesn't increment the counter unless it is accessed by a web user (this prevents ultiple increments from happening when editting a document internally while still allowing internal users to view the count info)
Type*
Formula
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

webUser := @IsMember("$$WebClient";@UserRoles);
profileName := "Counter for " + @Text(@DocumentUniqueID);


firstTime := @GetProfileField(profileName;"FIRSTACCESS");
lastTime := @GetProfileField(profileName;"LASTACCESS");
timeNow := @Now;


@If(firstTime="";@Do(@SetProfileField(profileName;"FIRSTACCESS";timeNow));" ");

currentCount := @GetProfileField(profileName; "COUNT");
newCount := @If(currentCount="";1;currentCount + 1);


finalCounter := "This page has been accessed " + @If(webUser;@Text(newCount);@Text(currentCount)) + " times. (FIRST: " + @Text(firstTime;"D0T1S2") + " -- LAST: " + @Text(timeNow;"D0T1S2") + ")";

@If(!webUser;@Return(finalCounter);"");

@SetProfileField(profileName;"COUNT";newCount); @SetProfileField(profileName;"LASTACCESS";timeNow);

finalCounter