Doclink does not work with LS created Doclink

Today I had an interesting issue I definitely need to put out here to be able to remember it in the future.

I used a piece of code (see below) to append a link to a document, sent out via an email message to another user. When the recipient opened that message and clicked the doclink a dialogue box came up “The Doclink database cannot be located.” asking the user to select the server where the linked database is located. This issue however did only happen in some circumstances.

' create notification document
 Set docMemo = New NotesDocument (db)
 With docMemo
  .CopyTo = vCopyTo
  .Subject = sSubject
 End With
 Set rtitem = New NotesRichTextItem (docMemo,"Body")
 Call rtitem.AppendText (sMessage)
 Call rtitem.AddNewline (2)
 Call rtitem.AppendDocLink (vDocLink,"")
 Call rtitem.AppendText (" <- link to document")
 Call docMemo.Send(False)

Researching that error message at the IBM knowledge base I found a document describing exactly the same issue.

The problem only arises in various circumstances where the linked document is found on a different server then the user’s mail file and the comment$ parameter of the AppendDocLink method is an empty string. The problem is described different for version 4 and 5 of Lotus Notes. However, I discovered it happening in Lotus Notes 6.5 too.

As a workaround it is suggested to not submit an empty string as comment$, this however is only working as long as the user ‘lives’ in the same hierarchy as the id (user) creating the document link.

Lessons learned: I guess that’s another point on the Best Practices list for future development – “Never leave the comment$ parameter empty”

Leave a Reply

Your email address will not be published. Required fields are marked *