How to move focus to an open uidoc?

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

End Sub

Subject: Try this

Paul,

Try to change this block :

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

with this “simple line”:

if not projectdoc is nothing then

call workspace.EditDocument(,projectDoc, false)

end if

The last parameter (false), will force lotus to show the current instance of the uidoc if it’s already open, otherwise it will open a new one.

Omitting the first parameter will let the document in the current state (edit mode or read mode) if it’s already opened.

Hope this helps

Renaud

Subject: Success! Thanks, Paul.

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

Subject: IsUIDocOpen works not allways

Hi,

…But to resolve the property IsUIDocOpen is not allways possible:

If you got the Document by

set doc = view.GetDocumentByKey(Key, true)

then the property seems not to be set.

But if you get the document with

set doc = database.getDocumentByUNID(sUNID)

then it works.

Very interessting… an surely well-founded.

Subject: IsUIDocOpen Not Working with GetDocumentByKey method

Hello,

Is this a bug in Lotus? We are on release 8.5.2 FP3 and the IsUIDocOpen property does not seem to be set if I access the NotesDocument via;

Set doc = view.GetDocumentByKey(key, True)