I have a form with a field called MainID containing the UNID of the document that I would like to use as a reference for the current doc. I have placed this code below on a button in the Action Bar hoping to be able to toggle the doc referenced in the MainID field off and on in the preview pane defined as “NotesPreview” in my frameset. Am I trying something impossible? or just not in the right way?
@Command([ShowHidePreviewPane];“”);
@SetTargetFrame(NotesPreview);
@Command([OpenDocument];0;MainID)
Thanks in advance!
Subject: Creating a pseudo parent/child relationship
The first argument to OpenDocument should be text; not sure whether that has anything to do with it. The other question is, what’s already in that frame? You’re not specifying a database, so if the frame has no contents, there’s no database context for the OpenDocument command to execute in.
Subject: Creating a pseudo parent/child relationship
In my code I open to a new window, not the preview pane, so not what you’re looking for. Sorry.
(Update go to ==> for a working approach)
Dim aSession As New NotesSession
Dim NotesUIWorkSpace As New NotesUIWorkspace
Dim aDB As NotesDatabase
Dim thisUIDoc As NotesUIDocument
Dim aDoc As Notesdocument
Dim aView As NotesView
Dim RelatedDocId As String
Set thisUIDoc = NotesUIWorkSpace.CurrentDocument
RelatedDocId = thisUIDoc.FieldGetText( RelatedDocIDFieldName$ )
If RelatedDocID <> "" Then
If Not thisUIDoc Is Nothing Then
Set aDB = aSession.CurrentDatabase
If Not aDB Is Nothing Then
Set aView = aDB.GetView( lookupViewName$ )
If Not aView Is Nothing Then
Set aDoc = aView.GetDocumentByKey( RelatedDocID, True)
If Not aDoc Is Nothing Then
’ Made No Difference Call NotesUIWorkspace.SetTargetFrame(“NotesPreview”)
Call NotesUIWorkspace.EditDocument( False, aDoc)
Else
Messagebox "No Doc"
End If
End If ''' END if Not aView Is Nothing
End If ''' END if Not aDB is Nothing
End If ''' RelatedDocID <> ""
End If ''' if not thisUIDoc is nothing
Subject: RE: Creating a pseudo parent/child relationship
Thank you for your efforts 
Subject: Solution - Lotus Script
Victory is MINE!
OK to get this to work, you need to have a doclink somewhere on the document. So I created a richtext field that I populated on the backend as follows
' Add DocLink
Dim s As New NotesSession
Dim Db As NotesDatabase
Dim view As NotesView
Dim dc As NotesDocumentCollection
Dim thisDoc As NotesDocument
Dim wrDoc As NotesDocument
Set thisDoc = Source.Document
Set db = s.CurrentDatabase
Set view = db.GetView("luByUniqID")
Set dc = view.GetAllDocumentsByKey( thisDoc.WorkReqDocId(0), True )
If dc.Count = 1 Then
Set wrDoc = dc.GetFirstDocument
Dim rt4dl As NotesRichTextItem
Set rt4dl = New NotesRichTextItem (thisDoc, "DocLinkHolder")
Call rt4dl.AppendDocLink( wrDoc, "")
Call thisDoc.Save(False, False, False)
End If
Then your action button code becomes:
Sub Click(Source As Button)
Dim aSession As New NotesSession
Dim NotesUIWorkSpace As New NotesUIWorkspace
Dim thisUIDoc As NotesUIDocument
Set thisUIDoc = NotesUIWorkSpace.CurrentDocument
If Not thisUIDoc.PreviewDocLink Then
thisUIdoc.PreviewDocLink = True
Else
thisUIdoc.PreviewDocLink = False
End If
End Sub
Tips, things I discovered - no idea why these make a difference.
tt did NOT work if the AppendDocLink had the third parameter, I have no idea why… But if the link looked like text with the hotspot around it, I got the message: “Unable to find or load linked document.”
If the Yellow Doclink icon was not visible it also did NOT work. Therefore I wasn’t able to hide the rich text field.
Maybe with some additional playing you can overcome these limits.
You might want to try and go back to your original @commands after you add the doclink and see if they work any better.
Subject: RE: Solution - Lotus Script
Thank you Stephen for all of your work. It is truely appreciated 
I have to confess, I am very inexperienced when it comes to LotusScript. I tinkered around with this on the weekend and couldn’t find where to place the first bit of script to make this work . Help ?!?!?!
Subject: RE: Solution - Lotus Script
The first bit of code AFAIR I put in the QueryClose Event.
Subject: Creating a pseudo parent/child relationship
Just tried your code and here is what the help says on @Command Open Document:
“A database must be open to a document view and the view must contain the document you want to open”
I’ve done something like this in another DB… Off to look at my code. Will post another reply shortly.