Search code examples
lotus-noteslotus-dominolotusscript

Find dead doc link in Lotus Script


I have a database and also doc links, I am trying to access those doc link through web. I have found the method appendDocLink in the help. Looked through all the NotesRichTextItem, Document and NotesDocument properties and methods, but there's nothing to check dead link.

What I am trying to do is get all the doclinks in lotus script, and then check to see if they lead to an existing doc or if its a dead link. If yes then will send a mail to the admin about the dead link. All these things I want to happen using a schedule agent.


Solution

  • You need to traverse the NotesRichTextItem using NotesRichTextNavigator and find the elements of type NotesRichTextDocLink.

    Dim rti As NotesRichTextItem
    Dim rtnav As NotesRichTextNavigator
    Dim rtlink As NotesRichTextDocLink
    
    Set rti = doc.GetFirstItem("Body")
    Set rtnav = rti.CreateNavigator
    
    If Not rtnav.FindFirstElement(RTELEM_TYPE_DOCLINK) Then
        Messagebox "No doclinks in Body item",, "No doclinks"
        Exit Sub
    End If
    
    Do
        Set rtlink = rtnav.GetElement
    
        'Use rtlink.DocUNID to get document UNID and try to fetch the document
    
    Loop While rtnav.FindNextElement
    

    I am not sure whether creating new NotesDocument object from rtlink.DocUNID would result in error or NOTHING (in case document with that UNID is not present). You will have to check that yourself.

    The above code snippet has been taken from here and modified for this answer.