Anonymous
Domino 2.0 Rich Internet Applications with IBM Lotus Notes/Domino
You are here: Today » Caching document info in a field
« Create an HTML table with all the fields in a document
Navigating to previous and next documents »

Caching document info in a field

This LotusScript function gives a document info paragraph in HTML containing the publish date, the last author, the tags (if any) with links to the overview of all documents tagged and the number of comments (if any). Take notice of how I figure out if there are any tags or comments.

The LotusScript

Function getPageInfo(doc As notesdocument)As String
    On Error Goto catch
    Dim tmp As New stringbuffer(10)
    Dim tmp2 As stringbuffer
    Dim sAppKey As String, sTag As String
    Dim i As Integer, iCount As Integer
    
    tmp.add doc.PublishDate(0)
    If doc.LastAuthor(0)="" Then
        tmp.add doc.Owner(0)    
    Else
        tmp.add doc.LastAuthor(0)        
    End If
    If Not Join(doc.DocTags, "")="" Then
        Set tmp2=New StringBuffer(10)
        sAppKey=doc.AppKey(0)
        For i=0 To Ubound(doc.DocTags)
            sTag=doc.DocTags(i)
            tmp2.add |<a href="/domino/pub/|& sAppKey & |?open&amp;tag=| & sTag & |">| & sTag & |</a>|
        Next
        tmp.add tmp2.collapse(", ")
    End If
    If Isnumeric(doc.responseCount(0)) Then
        iCount=doc.responseCount(0)
        Select Case iCount
        Case 0
        Case 1
            tmp.add iCount & | comment|
        Case Else
            tmp.add iCount & | comments|        
        End Select        
    End If
    
    getPageInfo=|<p class="info">| & tmp.collapse(" - ") & |</p>|
    Goto finally
catch:
    getPageInfo="Error " & Err & " in getPageInfo, line " & Erl & ": " & Error$
    Resume finally
finally:
End Function

The output HTML

The result of the function:

<p class="info">15/05/2008 17:13:26 - Michel Van Der Meiren - <a href="/dwdev/pub/BEDE-7B2NTV?open&amp;tag=wiki">wiki</a>, <a href="/dwdev/pub/BEDE-7B2NTV?open&amp;tag=test">test</a> - 7 comments</p>

Star rating

0%

Comments

To add a comment, log in or register as new user. It's free and safe.