Effective use of the FileCloseWindow Command

Jake Howlett, 18 October 2000

Category: Forms; Keywords: View Close Submit URL

When designing forms in domino we can easily use some of the same standard actions that we would use in the Notes Client i.e. EditDocument, FileSave, FileCloseWindow. Domino can then translate these in to actions that run via the web browser.

Most of these work perfectly, for example a submit button that contains both @Command([FileSave]) and @Command([FileCloseWindow]) or an "Edit" button with just @Command([EditDocument]). However, creating a Close button in forms and documents using just @Command([FileCloseWindow]) on its own can have undesirable effects.

The reason for this is that domino needs to know where to go after the close. In the Notes client this is not a problem as you don't need to go anywhere. Just show the window beneath it. The browser is different though as there is no window "beneath" it. For this reason domino has some rules for what to do after "closing" a window.

I've been doing a bit of testing (in R5) to see exactly what it is doing and am going to share it with you now.

If you're in a document with a URL similar to the one below, with either "?OpenDocument" or "?EditDocument" appended:

server/dir/db.nsf/view/document

the URL resulting from a FileCloseWindow will depend entirely on the view that is being used. If it is either the Name, Alias or UniqueID of the view then domino will open the following URL:

server/dir/db.nsf/ViewID?OpenView

Which is fine in most circumstances. If, however, you didn't know the view in which the document belongs when you created the URL and simply used a "0" in its place, like below:

server/dir/db.nsf/0/document

then domino does not know where to go afterward as there is no view called "0", even though the above URL is perfectly legal. The result would be to open the database at the root level. Not what most users would expect to happen.

Similarly, if you are in a new document ("?OpenForm") or your are in a view (via its template) then FileCloseWindow will also take you to the root database level:

server/dir.db.nsf?OpenDatabase

This all leads me to the conclusion that FileCloseWindow is not really of much use, on its own, and that it would be much more useful to use a more suitable function in its place. For example, you can have a button that says "Close" on it but actually all it does it use @Command([OpenView]) to return to a suitable view. You could also reopen the document in read-mode if a user hits close while editing an existing document or reopen a view if it is a new document by using the following simple formula:

URL := @If(@IsNewDoc; "view?OpenView"; @Text(@DocumentUniqueID) + "?OpenDocument");
@URLOpen(URL)


It is also worth pointing out that using FileCloseWindow in R5 is slightly different than in R4. This is due to the change in the _doClick function that domino uses to handle most calls to backend functions. The new R5 version calls the onSubmit event of the form before submitting it. If all you want to do is close the document and not do any of the validation you may have placed in the onSubmit event then this will cause you problems. Using @URLOpen gets around this as it doesn't need to submit the form, it just opens the new URL.