Reload a UI Document with single action

This is probably a long shot but worth a try…

When a document is open in the UI and the back end is changed by an agent or another user, the only way of loading the changes is to close and reopen the document.

I often wish that I could provide the user with a single ‘refresh’ button, but writing LotusScript to close and reopen the document does not work. It seems that the document always remains in scope and so a fresh version of it is not loaded.

Have I missed any tricks? Has anyone thought of a smart way of achieving this aim?

Alternatively, how can one elegantly instruct the user to close and reopen, given that they may have to grub around to work out where the document is. The best I can think of is suggest they press the Back button, but most of them don’t even realise there is such a thing.

Subject: Reload a UI Document with single action

Max,

if you are making changes to the back-enbd doc while it is opened, then the only changes you don’t see are with rich text items.

However, if agents are change the backend, and you want to refresh - then it is pretty easy.

save the document

set the saveOptions to 0

call uiDoc.close

set uiDoc = ws.editDocument( false, doc, false) 'read up on this

then in your post open event if the document have saveOptions then remove it.

I do this all the time, your user will see the screen flash, but always get a fresh copy of the document.

john

Subject: RE: Reload a UI Document with single action

John,

Are you sure that this works for you, because it doesn’t work for me?

Yes, it works if you make the back-end changes from the same client and I do this quite often as well.

But, what if the changes are made in another replica of the database and then replicated to the one that is open? Or the changes are made by another user on a different computer?

In your example, I expect that you will get a save conflict when you try to save (unless you are using a backend save with Force = True, in which case you will overwrite any other changes).

In the cases that interest me, the document is not open in edit mode, so I don’t need the first two steps that you list. Unfortunately, the sequence

uidoc.Close

ws.EditDocument(False, doc)

does not give me a completely fresh copy of the document. The only way I can get a fresh copy is to close first, then open it again in a separate operation. If the document is left open in any window at all, then even going back to the view and double-clicking does not get a fresh copy of the document.

Incidentally, I have found that the quickest (and I think only) way of testing whether I have a fresh copy of the document is to try doing a backend Save(False, False). If it fails, you know that something else changed the document.

Some of these characteristics have been obtained from experimentation. I don’t think the help spells it out very clearly. If I have missed anything, or anything I have said is wrong, please say so. Because I would love to have an operation for getting a completely fresh copy of the document and it always seems so strange that there is not one.

Subject: RE: Reload a UI Document with single action

Max,

You may try to enable document locking on the db properties.

This one will check against the administration server that the current document is a fresh one. If not, it will trigger an immediate replication. ( a fresh version may be issued by another server)

Ernesto

Subject: RE: Reload a UI Document with single action

Max,

Now I understand your question a little more. I did not realize that other users may have had the document, or a replica copy.

Yes you are right, I do do a force to overwrite, however my users are aware of this, and understand the ramifications.

The only other thing that I did similiar because of the notes chache was setting the document to nothing, and then doing a re-get of the document, but I forgot since it has been soo long.

John

Subject: RE: Reload a UI Document with single action

Try with Agent:

nid=doc.NoteID

Call uidoc.Close(True)

Set agent=db.GetAgent(“reopenDocument”)

agent.Run(nid)


Sub Initialize

Dim s As New NotesSession

Dim ws As New Notesuiworkspace



Dim db As NotesDatabase

Set db = s.CurrentDatabase



Dim agent As NotesAgent

Set agent = s.CurrentAgent



Dim nid As String

nid=agent.ParameterDocID



If(nid="") Then

	Messagebox "ParameterDocID nije predan!"

	

	Exit Sub

End If



Dim doc As NotesDocument

Set doc=db.GetDocumentByID(nid)



Dim uidoc As NotesUIDocument

Set uidoc=ws.EditDocument(False, doc)

End Sub

Subject: RE: Reload a UI Document with single action

Sorry, I only just noticed that you had posted this answer.

I have just tried it out and it works perfectly. Thank you very much. This will help me make a much more elegant and user friendly solution to my problem.