Subject: RE: Help with agent to modify a field when previewed
If you need to do something that the user doesn’t have access to do, you can generally do so with an agent called with NotesAgent.RunOnServer method – this agent runs on the server with the signer’s authority. However, this only works if the database is on a server – not in a user’s local replica. They can make a change to the document in their local replica, but this change will not replicate to the server unless the server recognizes the user’s authority to make the change.
You might want to reconsider your design approach. There are some drawbacks to doing this the way you want to do it.
To begin with, you will need to deal with save conflicts, since it’s very likely two users will start to read some document at the same time.
If you have multiple replicas of the application, replication conflicts are guaranteed.
Performance may suffer because you’re modifying documents unnecessarily, causing lots of churn in the view indexes and making the database use space inefficiently.
You may have to use a non-summary field for your “read by” list. Depending how many users of this database there are, the list of who has read the document may push it over the limit for summary information in a single field or in the document as a whole.
You’re overwriting system information that would tell you when the document was last edited – you can see the last however many edit times you specify in the $Revisions field, but you can’t distinguish “real” edits.
Just because the user had the document open once, is no guarantee that they’ve read it. Especially if you’re tracking opening in the preview pane, they might have arrowed past it and it was on their screen for one second or less. If this is important information that you want to make sure has been read and understood, it’s better to give them an action button they can click to say that they’ve read the document.
If your need to track readership is not that strict that the user needs to manually affirm understanding, then the system already tracks who has read each document, and you can use the Notes API to retrieve the list of unread documents for each user. Couldn’t you use this to tell whether documents have been read? That way, users could manually mark as unread any document they didn’t actually take time to read after they opened it.
Alternately, if you could keep track of this information in another database, perhaps even a non-Notes database, you could use @MailSend to have users automatically send in “read slips” to a mail-in database that tracks the reader information for each user, discarding any duplicates. It could consolidate the information in a central location which whoever needed to, could read (e.g. you could use @DbLookup to pull up reader list information for the document you’re looking at, on demand).