Copying Anchor links

I have seen some posts on the R5 forum, but no solutions. How are others handling this issue?

On our intranet, users can edit documents that have a richtext field. If they are not ready to post the changes, they can save the document as a draft. The Save as Draft button creates a copy of the original document, with a docid reference back to the original. When the user is ready to post the changes a lotusscript procedure copies all fields of the draft to the original document using the lines:

Set originalDoc = db.GetDocumentByUNID( draftDoc.OrigID(0))

	Call draftDoc.CopyAllItems( originalDoc, True )

Then the draft document is deleted. This procedure is used so that the original document is maintained and all existing links to that document on the intranet will still work.

All works fine - except for anchor links. Any anchor links changed or added on the draft don’t work once copied to the original because the links are referencing the draft document, which has been deleted.

Any solutions to this? Thanks

Subject: Copying Anchor links

You would need to update the links after copying. You should probably be able to do that with the NotesRichTextDoclink class. If that messes up the anchors, you would need to use the APIs or a third party product such as our Midas Rich Text LSX, which has allowed manipulation of such links since before anchors were added in R4.6x, but would also work in R5/ND6/ND6.5.

Subject: RE: Copying Anchor links

Thanks! It looks like the NotesRichTextDoclink class should work for me. I’ll post code once I get something working.

Subject: RE: Copying Anchor links

The NotesRichTextDoclink class works great. Here’s my sub that I call after copying all items from the draft to the original document:

Sub FixAnchorLinks(origDoc As NotesDocument, draftDoc As NotesDocument)

Dim rti As NotesRichTextItem

Dim rtnav As NotesRichTextNavigator

Dim rtlink As NotesRichTextDocLink



Set rti = origDoc.GetFirstItem("Body")

Set rtnav = rti.CreateNavigator

'Get first doclink

Set rtlink = rtnav.GetFirstElement(RTELEM_TYPE_DOCLINK)

'Loop through all doclinks

While Not rtlink Is Nothing

	'From Notes Help, check if link has a doc component

	If rtlink.DocUnID <> String$(32, "0") Then

		'If the DOCUnID is equal to the draft doc, change it to the original doc

		If rtlink.DocUnID = draftDoc.UniversalID Then

			rtlink.DocUnID = origdoc.UniversalID

		End If

	End If

	Set rtlink = rtnav.GetNextElement(RTELEM_TYPE_DOCLINK)

Wend

End Sub