LS Button : close document and refresh view -> Refresh doesn´t work

Hi, I ´ve a form with the following "Save/Close" button.
I want to save the document and refresh a special view in that current database.
The save/close function is working but no refresh in the view.
I don´t know , why.

Maybe someone can help me.

Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim uidoc As NotesUIDocument
Dim view As NotesView
Dim db As NotesDatabase

Set uidoc = workspace.CurrentDocument
Set db = session.CurrentDatabase
Set view = db.GetView( "Profildokumente" )

Call uidoc.Save
Call view.Refresh
Call workspace.ViewRefresh
Call uidoc.Close
End Sub

This is not an easy task to do.

First problem: Your code will be executed until the end and THEN the document will close: Any code trying to access the "new" frontend context (the view Profildokumente will be visible AFTER the document is closed), will fail.

Therefor the "workspace.ViewRefresh" in your code will not do anything...

Second problem: NotesView.Refresh does NOT do what you expect. It does not "rebuild" the view to reflect your changes... it refreshes your LotusScript- object "view" to get all the changes that have been done to the view in the backend since you got that object... It is absolutely useless in this context.

If you need to rebuild a view in backend, that is not open in your client, then there is no way to do this programatically EXCEPT using NotesSession.SendConsoleCommand and run an updall yourdatabase.nsf -R -T "ProfilDokumente".

If you need to refresh a currently open view, then there are two ways to do this:

First: via remote binding you can "react" on an event of the document (QueryClose) from within the view and could run a workspace.ViewRefresh for the workspace from the context of the view...

Remote Binding is quite advanced stuff and not easy to implement

It looks like:

on Event QueryClose of uidoc call MyOwnQueryClose

In "MyOwnQueryClose" you have access to global variables from the "calling" context and could run a workspace.ViewRefresh there...

Second: You could have your refresh code in the "terminate" of the form: I think that at that point the window is already closed and using a new NotesUIWorkspace + ViewRefresh there might work...