How to give focus to already opened (unsaved) UIDocument

Ok, this one has kept me busy for quite a time. Hope someone of you can point me in the right direction:

In brief: How to overcome the limitations of NotesUIWorkspace.EditDocument which doesn’t allow to ‘switch’ to an UNSAVED document which is already open in the ui? I’m using the ‘newinstance’ parameter but it prompts me with ‘Cannot locate default form’ and when I’m setting one as default form, it opens the document to that form but in a new tab window instead switching to the already opened document.

What I want to achieve is, the user presses a button in a main form and a new (draft) document is created and opened in which the user may play around. This draft document I do not want to save.

I know there are some kind of other approaches like dialogboxes or saving the drafts and cleaning up afterwards, but the question remains: How to do this without saving the draft.

What I already have achieved is to get a permanent handle to the uidoc (as long as the main form stays open) by using a global variable of the main form. Unfortunatelly Lotus has seemed to miss out a function for just bringing a NotesUIdocument back to focus again.

In searching the forum I also found a post stating you should use NotesUIDocument.GotoField(“FieldName”) which happily changes focus as long as you are in debug mode, but fails if you try it without debugger.

This is really one of those little problems that can drive you nuts :slight_smile:

Any help on this would be highly appreciated.

Cheers

Jens

Subject: How to give focus to already opened (unsaved) UIDocument

Try NotesUIWorkspace.URLOpen passing it the NotesURL of the draft document.

i.e.

Call ws.URLOpen(draftDoc.NotesURL)

Subject: RE: How to give focus to already opened (unsaved) UIDocument

Hello Andrew,

unfortunatelly this doesn’t solve the problem when I’m not willing to save the document. With a unsaved draft the method returns “The document specified by the link cannot be located within the linked-to database”.

Sure enough it would be possible to save the draft document and remove it afterwards but I really don’t want to got this way.

Any other suggestion would be great

Thanks

Jens