Find and use a doclink in a richtext field


  1. Find doclink in a richtext field.Doclink in a richtext field
  2. Use doclink to get linked document and retrieve some values from it.

The code

Not that hard to understand…

Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim linkdoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Dim rtrange As NotesRichTextRange
Dim rtlink As NotesRichTextDoclink
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
If dc.Count = 0 Then
	Messagebox "No document selected",, "No doc"
	Exit Sub
End If
Set doc = dc.GetFirstDocument
While Not(doc Is Nothing)
	'First find your richtext item
	Set rtitem = doc.GetFirstItem("Body") 'Change this to your rtfield
	If Not(rtitem Is Nothing) Then
		Set rtnav = rtitem.CreateNavigator
		'Use the first doclink
		If rtnav.FindFirstElement(RTELEM_TYPE_DOCLINK) Then
			Set rtrange = rtitem.CreateRange
			Call rtrange.SetBegin(rtnav)
			Set rtlink = rtnav.GetElement
			Dim linkdb As New NotesDatabase("", "")
			'Investigate the link to find the linked document
			If linkdb.OpenByReplicaID (rtlink.ServerHint, rtlink.DBReplicaID) Then
				Set linkdoc = linkdb.GetDocumentByUNID (rtlink.DocUNID)
				If Not(linkdoc Is Nothing) Then
					'Here comes the code where you do things with the related doc
				End If
			End If
		End If
	End If
	Set doc=dc.GetNextDocument(doc)
End Sub


  1. It would be interesting to add the current document as a doclink in the linked (target) document, so you could create cross connections.

    of course you should check if such a document link isn’t already available on the document.

    question how would you create a doclink from source into a target in a specific field in an automated process ?

  2. would be intressting so see if you would create cross connections from each doclink in the source into the target document(s)

    how would you create such a linking in an automated process (agent) ?

  3. If I understand your question right I think this isn’t that hard (and I’m quite sure I coded this in the past) using AppendDocLink in LotusScript. Is that what you meant?


Submit a Comment

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

48 + = 58

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>