Action Logs are something I'm sure we've all added to the bottom of a Domino web form. Here's an example of one I added to a recent Domino-based app I created and then wrapped with Bootstrap.
The log is shown to the user as a three column table(when, who, what) with the latest action first.
My approach to storing this data has always been to use a single multi-value text field. The value stored might look something like this:
24/09/2013 17:08:12^^24 Sep '13^^17:08^^Joe Bloggs/ROCKALL^^Document Created 24/09/2013 17:08:12^^24 Sep '13^^17:08^^System Admin/ROCKALL^^'New Document' email sent to related users 24/09/2013 17:21:57^^24 Sep '13^^17:21^^Jake Howlett/ROCKALL^^Status changed to Published 24/09/2013 17:21:57^^24 Sep '13^^17:21^^System Admin/ROCKALL^^'Document Published' email sent to related users
This field is built up by recurring calls to a LotusScript method called LogAction() in the WQS agent of the document.
The HTML table the user sees is generated in a Computed Value section that uses an @For() loop to create a <tr> for each entry in the log.
There are inherent limitations to this approach:
- Limit of the amount of data the backend field can store.
- Limit of HTML the Computed Value that displays the table on the web can store.
These limitations can be worked round, but for the majority of cases the above solution will suffice.
The limitations became an issue recently when I was tasked with including user's comments in the Action Log. So that the log would look something like this:
Notice the comment on the 2nd row down!?
By adding comments, the chance of reaching the data limitations has greatly increased, becoming almost inevitable.
To avoid the limitation I chose to add each individual comment in a field of its own.
Each time an action is performed and logged with an accompanying comment a field called ActionComment_X is added, where X is the number stored in a field called ActionCommentCount incremented by 1.
The backend documents start to look like this:
Then, in the ActionLog field we add a reference to this comment field as an extra delimited field on each line. Notice in the values below that the 3rd line down ends in ^^ActionComment_1
24/09/2013 17:08:12^^24 Sep '13^^17:08^^Joe Bloggs/ROCKALL^^Document Created^^ 24/09/2013 17:08:12^^24 Sep '13^^17:08^^System Admin/ROCKALL^^'New Document' email sent to related users^^ 24/09/2013 17:21:57^^24 Sep '13^^17:21^^Jake Howlett/ROCKALL^^Status changed to Published^^ActionComment_1 24/09/2013 17:21:57^^24 Sep '13^^17:21^^System Admin/ROCKALL^^'Document Published' email sent to related users^^
When the HTML table is generated and each line in the ActionLog field is exploded on the delimiter ("^^") we can simply add the value stored in the comment field, like so:
@If(@Word(log[n];6)=""; ""; @GetField(@Word(log[n];6))
All that remains is to markup the comment in a <blockquote> tag and add a sprinkle of CSS to make it look like a quote.
The only remaining issue is that, if people type in huge great long comments, the amount of HTML generated by the Computed Value quickly reaches its limit.
To get round this I added an ellipsis (copying off Gmail a little) to the end of a truncated comment like so:
Clicking on this ellipsis "button" uses Ajax to go fetch the rest of the comment.
It's a solution I'm happy with and I've been sitting on for a while, thinking of sharing. Just don't know what interest there is? If there is some I can build a demo/download.