AppendDocLink generates "File does not exist" error

I have a form in my database with a button used to insert a text hotspot into a rich text field. It uses LotusScript to produce a dialog box containing a view. On clicking a document and ‘OK’-ing, a link to the selected document from the view is generated.

This all works fine on my own PC and Notes ID, with the database held locally, but the other two other users who have tested the database (also locally on their own systems) report an error.

Initially, the dialog box opens, without displaying the view (it’s just blank), and an error box follows immediately with “File does not exist”. After clicking OK here, both dialogs disappear, and are followed by another error box, saying “Notes Error - File does not exist”.

At this precise moment, I don’t have access to another ID or system (I’m working on this) but, I wondered if anyone had any suggestions meanwhile. The other testing users have had manager access, just as I have. I’ll include the button code below, though my apologies as it is a bit messy.

Many thanks for any thoughts you may have.

Adam

Sub Click(Source As Button)

Dim s As New NotesSession

Dim ws As New NotesUIWorkspace

Dim thisdb As NotesDatabase

Dim coll As NotesDocumentCollection ' collection returned from PickListCollection

Dim otherdoc As NotesDocument ' this is the doc to create a link to

Dim thisdoc As NotesDocument ' the new doc that the link is being added to

Dim rtitem As NotesRichTextItem ' required for AppendDocLink

Dim nitem As Variant ' used to get a handle on the NotesRichTextField

Dim olduidoc As NotesUIDocument ' the original instance of the uidoc

Dim newuidoc As NotesUIDocument ' the new instance of the uidoc after the doc link has been added

Dim Workspace As New NotesUIWorkspace

Dim Session As New NotesSession

Dim doc As NotesDocument

Dim uidoc As NotesUIDocument



Dim servN As String

Dim dbN As String

Dim db As NotesDatabase

Set db = session.CurrentDatabase

servN = db.Server

dbN = db.FileName



Set thisdb = s.CurrentDatabase

Set olduidoc = ws.CurrentDocument ' current uidoc

Set thisdoc = olduidoc.Document ' doc in memory, not yet saved

Set uidoc = Workspace.CurrentDocument

Set doc = uidoc.Document



olduidoc.Refresh True 'capture any data added to the field since last save

’ if this is a new, unsaved doc we need to set the form field

Set nitem = doc.GetFirstItem( "policy" )

If nitem Is Nothing Then

	doc.Form = "policy"

End If

’ if this is a new, unsaved doc we need to create a new NotesRTFItem

Set nitem = doc.GetFirstItem( "relprinciple_1" )

If nitem Is Nothing Then

	Set nitem = New NotesRichTextItem(doc, "relprinciple_1")

End If

’ now we write some content into the field

If ( nitem.Type = RICHTEXT ) Then

	Set rtitem = nitem

	Call rtitem.Update

End If

’ select the doc to link to

Set collection = workspace.PickListCollection( _

PICKLIST_CUSTOM, _

False, _

servN, _

dbN, _

"principle", _

"Select Related Principle", _

"Please select a principle to link to." )

’ if a doc isn’t selected exit

If collection.Count = 0 Then

	Messagebox "No link was appended." ,,"Operation cancelled"

	Exit Sub

End If

’ get the doc to link to

Set otherdoc = collection.GetFirstDocument

’ grab some values from that doc

’ thisdoc.refnumber_1 = otherdoc.refnumber_1

’ thisdoc.CustomerName = otherdoc.CustomerName

’ get the RichTextField in the current uidoc

Set nitem = thisdoc.GetFirstItem( "relprinciple_1" )

’ add the doc link

’ NOTE: this is being done to the backend doc that exists in memory

Dim ref As Variant

Dim titl As Variant

ref = otherdoc.GetItemValue("refnumber")

titl = otherdoc.GetItemValue("ptitle")



If ( nitem.Type = RICHTEXT ) Then

	Set rtitem = nitem

	If rtitem.GetUnformattedText() = "" Then Else Call rtitem.AddNewline(1)

	Call rtitem.AppendDocLink(otherdoc, "Document Link", (ref(0) + | - "| + titl(0) + |"|))

	Call rtitem.Update

End If	

’ set the SaveOptions field so that when the uidoc is closed, the user won’t be asked to save

thisdoc.SaveOptions = "0"

doc.SaveOptions = "0"

’ close the uidoc. It won’t actually happen until the code is finished executing

Call olduidoc.Close(True)

Call uidoc.Close(True)

’ create a new uidoc and open the backend doc that is still in memory with added doc link

’ Set newuidoc = ws.EditDocument(True, thisdoc) —Creates a double instance of the UI Doc

Set newuidoc = workspace.EditDocument(True, doc)

’ delete the reference to the old uidoc

’ this is necessary because the code below affects it if left in memory

Delete olduidoc

’ Delete uidoc

’ re-associate the variable with the backend doc

’ have to do this because the olduidoc reference was deleted

Set thisdoc = newuidoc.Document

Set doc = newuidoc.Document

’ remove the SaveOptions field so the doc can be saved

Call thisdoc.RemoveItem( "SaveOptions" )

Call doc.RemoveItem( "SaveOptions" )

End Sub

Subject: AppendDocLink generates “File does not exist” error

have you tried running in debug mode on user’s PC to see what line the code bombs at?

Subject: RE: AppendDocLink generates “File does not exist” error

Hi, thanks for the suggestion. I haven’t been able to do this yet, unfortunately. I won’t be able to for some time either - though I realise that this would be the logical next step. I guess I was hoping someone had heard of this sort of behaviour, while I wait for access. I’ll post again once I have access to a second computer/ID.

Thanks,

Adam