Swaping parent/child doclinks

I’ve scrounged pretty seriously for code to include a link to a child from a parent document and vice versa. In the end, I was able to make it work but after far too much thrashing.I may need it in the future and am posting it here in case I lose it.

Here’s the stripped down code to exchange links;

’ This is the basis for creating a new document and swapping doclinks.

’ This is triggered from within an open document.

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim session As New NotesSession

Set db = session.CurrentDatabase

Dim db2 As New NotesDatabase(“Glinda/UniSURe Corporation”, “dform.nsf”)

Set doc = db2.CreateDocument

doc.Form = “Problem Report Form”

Dim rl2 As NotesRichTextItem

Set rl2 = New NotesRichTextItem(doc,“CSDocLink”)

Call rl2.AppendDocLink(workspace.currentdocument.document,“ReferenceLink”)

Dim rl3 As NotesRichTextItem

Set rl3 = New NotesRichTextItem(workspace.currentdocument.document,“ReferenceLink”)

Call rl3.AppendDocLink(doc,“CSDocLink”)

Call doc.Save(True,False)

Call uidoc.Save