AppendocLink

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)

Subject: AppendocLink

I think your problem revolves around using the Front end and Back end document. If I read your code correctly you create a new UIDoc then get the backend Doc from it. You then work with the backend doc and append the Doclink to the RTF which is OK. However, from what I can see the UIDoc is still open and would be subsequently saved. I think that you might have to do a UIDoc.reload() , which then makes the UIDoc = Doc.

Mixing code that operates on the UIDoc and Doc can create some problems.

Subject: AppendocLink

It might be a good idea to save the document before it’s used in AppendDocLink.

You code:

Call rtf.AppendDocLink( doc, “Apps Log Link”) ’ Doc is the original doc (apps log)

Call rtf.Update

Call doc.Save(True,True)

try this one:

Call doc.Save(True,True)

Call rtf.AppendDocLink( doc, “Apps Log Link”) ’ Doc is the original doc (apps log)

Call rtf.Update

Call doc.Save(True,True)

regards

Litty Joseph

Subject: RE: AppendocLink

I gave that a try. It still doesn’t save the doclink. I did notice two document windows opened one containing the link and one without the link. I tried saving them both and it doesn’t work. I am at lost as to why this is so difficult.

I Filesave is done in the post open event and another when the assign project# button is clicked. The document cannot be saved with an empty project number. Could the FileSave be in this routine be overwriting my doc link? This is in the UIDoc when the users executes the assign project # button.

Subject: RE: AppendocLink

Please read the Update rich text tip.

Subject: RE: AppendocLink

Thanks for the tip. This help resolve my issues.