I have a database with projects and each project has many related deliverables. The deliverables are related by UNID, but aren’t children of the project. I will call the project the “parent” and the deliverables the “children” though this isn’t technically correct terminology.
When my user is inside a child, I want to create an [Open Project] button that will open the parent document.
I know how to check and see if the parent is already open and when it ISN’T. I open the parent in read mode…no problem.
When the parent IS open, I send a message stating, “The project is already open.” This ISN’T what I want to do. I want to move focus to the parent project document that is already open, I don’t want to just tell the user that it’s open. How do I move focus to an already open uidoc?
Thanks, Paul.
Here is the code in my [Open Project] (i.e. open “parent”) button…
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim workspace As NotesUIWorkspace
Set workspace = New NotesUIWorkspace
Dim projectDoc As NotesDocument
Set projectDoc = db.GetDocumentByUNID(uidoc.FieldGetText("ProjectUID"))
Dim alreadyOpen As Boolean
alreadyOpen = projectDoc.IsUIDocOpen
If (alreadyOpen = False) Then
'using EditDocument with False opens in read mode
Call workspace.EditDocument(False,projectDoc)
Else
Messagebox ("The project is already open.")
End If
Yes, this works perfect. Thank you! I’ve included some information below that I feel adds some clarity since when I review help and the “very simple” solution I’m unable to figure out why things are occuring the way they do.
If Not projectDoc Is Nothing Then
Call workspace.EditDocument("",projectDoc,"","","", False)
End If
*** MORE OR LESS COMPLETELY EQUIVALENT TO ***
Dim alreadyOpen As Boolean
alreadyOpen = projectDoc.IsUIDocOpen
If (alreadyOpen = False) Then
'using EditDocument with False opens in read mode
Call workspace.EditDocument(False,projectDoc)
Else
'The 6th parameter is newInstance. False changes focus to an existing instance of notesDocument if one exists in the
'workspace (workspace is important...we're talking about UI here not the backend), or to a new instance if one does not
'exist.
Call workspace.EditDocument("",projectDoc,"","","", False)
End If