DocLink Won't Attach to RT Field

Hi, I am attaching a doclink to a non-Response document via an agent. I am inheriting the field values including the UNID to capture the correct document. It captures the correct “parent” doc except the doclink is not appending the the rich text field on my form (doclink)… When I modify my code to send an email it works fine.

Please help.

Sub Initialize

Dim ws As New notesUIworkspace

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim memo As NotesDocument

Dim uidoc As NotesUIDocument

Dim s As New NotesSession

Dim rtf As NotesRichTextItem

Dim parent As NotesDocument 



Set uidoc = ws.currentdocument

Set db = s.CurrentDatabase

Set doc = uidoc.Document





Set parent = db.getDocumentByUNID( doc.UniversalID )







Set rtf = New NotesRichTextItem( doc, "doclink" )

Call rtf.AppendDocLink( parent, "Click to open document")

End Sub

Subject: DocLink Won’t Attach to RT Field

Rich text fields don’t update in the ui. You need to save the document then close and open it for the doclink to appear. This can all be done programatically of course, as in this post here:

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/dd507a5be7cc2e4285256eec005f56ef?OpenDocument

Subject: RE: DocLink Won’t Attach to RT Field

Thanks. I am giving it a try but it keep crashing when attempting to set uidocNew. Any clues?

Here’s my code:

Sub Initialize

Dim ws As New notesUIworkspace

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim memo As NotesDocument

Dim uidoc As NotesUIDocument 

Dim uidocNew As NotesUIDocument

Dim s As New NotesSession

Dim rtf As NotesRichTextItem

Dim parent As NotesDocument 

Dim strFieldname As String



Set uidoc = ws.currentdocument

Set db = s.CurrentDatabase

Set doc = uidoc.Document





Set parent = db.getDocumentByUNID( doc.UniversalID )





Set rtf = New NotesRichTextItem( doc, "doclink" )

Call rtf.AppendDocLink( parent, "Click to open document")





If s.NotesBuildVersion >= 190 Then

	rtf.Update ' ND6 only

Else

	Call doc.ComputeWithForm(True, False) 

End If



doc.SaveOptions = "0" 

Call uidoc.Close(True)

Set uidocNew = ws.EditDocument(True, doc, , , , True)

Delete uidoc

uidocNew.Document.RemoveItem("SaveOptions")

If strFieldname <> "" Then uidocNew.GotoField(doclink)

Subject: SOMEONE PLEASE HELP!

WHY IS MY CLIENT CRASHING??

I am crashing when attempting to set the uidocNew, according to the linked example. I am executing this appenddoclink on a form Queryopen event via an agent.

Is that incorrect?

Subject: RE: SOMEONE PLEASE HELP!

All you need to do in order to “inherit” a doc link is to put @InheritedDocumentUniqueID in a computed-when-composed field on the form. (Your code is trying to create a doclink to the current document – you can never “inherit” a UNID, since they are by definition unique across all replicas of a database.)

Subject: RE: SOMEONE PLEASE HELP!

WOW!! Talk about a waste of time… Thank you. I forgot about that formula… works perfectly now. Thanks Stan!

Subject: RE: SOMEONE PLEASE HELP!

Can you debug that code?

In QueryOpen, you do get a NotesUIDocument object, but it doesn’t contain much useful (QUERYOpen happens BEFORE the document has been opened in the UI). In particular, the .Document property does not return a NotesDocument object. I don’t think that outsourcing the code to an agent would change that.

Subject: DocLink Won’t Attach to RT Field

Stacey,

I know this might sound crazy… but I’m in Notes 6.5 and I couldn’t get my appended doclinks to show if it was the LAST text in the Rich Text item.

I had to append my doclink then add some newlines or spaces to make the doclink show. It was odd.

Subject: Client Keeps Crashing!!! PLEASE HELP

Can anyone provide me another example? My client is still crashing here on the example provided…

Set uidocNew = ws.EditDocument(True, doc, , , , True)

Subject: DocLink Won’t Attach to RT Field

Also where is the doc.save…