SNTT - Updating a UI document from an agent called with RunOnServer
Here's a technique to run an agent on the server, close the UI document, and have it reopen showing the updates done in the agent. In this case my agent is issuing LC LSX calls to update data from DB2. The following code is in a Hotspot button on the document. The tricky part here is knowing to use Delete on the NotesDocument. You have to delete the document from the object cache after the agent runs to force it refresh when you reopen it.
Sub Click(Source AsButton) Dim uiws AsNewNotesUIWorkspace Dim uidoc AsNotesUIDocument Dim db AsNotesDatabase Dim agent AsNotesAgent Dim doc AsNotesDocument Dim noteid AsString
Set uidoc = uiws.CurrentDocument Call uidoc.Save
Set db = uiws.CurrentDatabase.Database Set agent = db.GetAgent("Get Account Info") Set doc = uidoc.Document noteid = doc.NoteID
If agent.RunOnServer(doc.NoteID)<> 0 Then Msgbox"There was an error looking up the account information.", 48 _ ,"New Account Setup" EndIf
Call uidoc.Close(True) Delete doc Set doc = db.GetDocumentByID(noteid) Set uidoc = uiws.EditDocument(True, doc) EndSub
This LotusScript was converted to HTML using the ls2html routine, provided by Julian Robichaux at nsftools.com.