My customer wants to have the application create a link to another document. While the below code produces no errors, neither does it produce a document link anywhere on the current document. Any constructive help is greatly appreciated as to why this is not working. The end user has DocA opened and clicks on an action bar button that has
@Command([ToolsRunMacro]; “(LinkToDocB)”)
The (LinkToDocB) agent is as follows
On Error Goto errHandle
Dim s As New NotesSession
Dim db As NotesDatabase
Dim cardb As NotesDatabase
Dim carview As notesview
Dim cardoc As NotesDocument
Dim ws As New NotesUIWorkspace
Dim carnum
Dim thisdoc As NotesDocument
Dim rtitem As NotesRichTextItem
Set db=s.CurrentDatabase
'Have end user select the DocB to link
carnum = ws.PickListStrings(PICKLIST_CUSTOM, False, db.Server, “fullfilepath”, “LinkToDocA”, “Link to DocB”, “Select the DocB to link”, 1)
If carnum(0)<>“” Then
Set cardb = s.GetDatabase(db.Server, “fullfilepath”)
Set carview =cardb.GetView(“LinkToDocA”)
'Get ahold of the DocB they selected
Set cardoc = carview.GetDocumentByKey(carnum(0))
Set thisdoc=ws.CurrentDocument.Document
Set rtitem = thisdoc.GetFirstItem(“linkedtoDocA”)
'Create a link to the DocA on this document
Call rtitem.appenddoclink(cardoc,"Click to open DocA " & carnum(0), "Click to open DocA " & carnum(0))
Call thisdoc.Save(True, False)
If Not cardoc.IsUIDocOpen Then
If cardoc.HasItem(“linkedtoDocB”) Then
Set rtitem = cardoc.GetFirstItem(“linkedtoDocB”)
Else
Set rtitem = cardoc.CreateRichTextItem(“linkedtoDocB”)
End If
'Create a link to this document on the DocA if no one is in it
Call rtitem.AppendDocLink(thisdoc, "Click to open DocB " & thisdoc.ReqNum(0), "Click to open DocB " & thisdoc.ReqNum(0))
Call cardoc.Save(True, False)
End If
Else
Msgbox “No link established”
End If
I realize all this should be working on the backend doc, and I am closing and reopening the UIDoc to try to view the changes and they are not there. Funnily enough, the link on DocB is there. Thank you.