I am having serious issues with appenddoclink. I don’t how to make this work because it looks like another save is overwriting the link. The document closes and reopens and the link is shown. When save&close button is used on the document, the link disappears. I have an action button in Doc that creates Doc1. I want to be able to put a link to Doc in Doc1 and a link to Doc1 in Doc . I’m just try to get the link to Doc in Doc 1 at the moment and it is not working.After the Agent runs to create the doc and appendlink, a buton is used to create a document # and FileSave is done in this code. I suspect this may be overwriting the doclink. Any help is appreciated.
This code exists in PostOpen Event
ProjType:= ProjType;
temp:= temp;
@If(@IsNewDoc= 1; @Set(“temp”;@Prompt([OkCancelList]; “Project Type”; “Is this a Research Project?”; “”; “Yes” : “No”)); “”);
@SetField(“ProjType”; temp);
@PostedCommand([FileSave]);
@Command([RefreshHideFormulas])
The Create Doc1 action button calls agent to run:
Dim s As New NotesSession
Dim w As New NotesUIWorkSpace
Dim db As NotesDataBase ' The current Database
Dim doc As NotesDocument ' Document in the current database
Dim uidoc As Notesuidocument ' CPF UIDoc
Dim mainuidoc As NotesUIDocument ' Current UIDoc
Dim temp As NotesItem
Dim temp1 As NotesItem
Dim temp2 As NotesItem
Dim temp3 As NotesItem
Dim temp4 As NotesItem
Set mainuidoc = w.CurrentDocument
Set doc = mainuidoc.document
'check the document for edit or read mode
If mainuidoc.EditMode Then
edit = "True"
Else
mainuidoc.EditMode = True
End If
Set doc = w.CurrentDocument.Document ' Reference the currently open document
Set db = s.CurrentDataBase ' The current database
' Get the environment variables
CPFServer = s.GetEnvironmentString ( "CPFServer" ) ' Destination database server
CPFFilePath = s.GetEnvironmentString ( "CPFFilePath" ) ' Destination database file path
' Create the new cpf document
Set uidoc =w.ComposeDocument(CPFServer,CPFFilePath,"CPF")
Set doc1 = uidoc.document
Set temp = doc.GetFirstItem("demo_projname")
Call temp.CopyItemToDocument(doc1,"ProjName")
Set temp2 = doc.GetFirstItem("demo_projleader")
Call temp2.CopyItemToDocument(doc1,"ProjLeader")
Set temp3 = doc.GetFirstItem("demo_acctmanager")
Call temp3.CopyItemToDocument(doc1, "AccountManager")
Call doc1.save(True,True)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Set doc = mainuidoc.Document
'Set temp4 = doc1.GetFirstItem("ProjectNumber")
'Call temp4.CopyItemToDocument(doc,"demo_projnum")
'Call doc.Save(True, True)
'Get the rtf field where the reference is to be written
Call uidoc.GotoField( "RefNum" )
Dim rtf As NotesRichTextItem
Set rtf = New NotesRichTextItem( doc1, "RefNum")
Call doc1.Save(True,True)
'add apps log link in the cpf doc
Call rtf.AppendText (" " )
Call rtf.AppendDocLink( doc, "Apps Log Link") ' Doc is the original doc (apps log)
Call rtf.Update
Call doc.Save(True,True)
doc1.SaveOptions = "0"
Call doc1.Save(True, False)
uidoc.Close
Set uidoc=w.EditDocument(True,doc1)
Call doc1.RemoveItem("SaveOptions")
Call doc1.Save(False,False)