I’ve searched for quite some time and haven’t found a solution to my problem. I’ve got a form (Form A) with an embedded view. When I save and close Form A, I would like to (behind the scenes) select all of the documents in the embedded view and open/save/close each of the documents in order to refresh the computed fields on each of those docs. Is this possible? Any and all help is much appreciated.
Jeremy
Subject: Refresh all docs in embedded view after closing form
It’s fairly easy to do this using lotusscript.
You will have to add a bit of code in the “PostSave” event:
(assuming db points to current database):
Dim view as NotesView
Set view = db.GetView (“TheEmbeddedViewHere”)
Dim CurrentDoc as NotesDocument
Set CurrentDoc = view.GetFirstDocument
While not CurrentDoc is nothing
Call CurrentDoc.ComputeWithForm (False, False)
Call CurrentDoc.Save (False, False)
Set CurrentDoc = view.GetNextDocument (CurrentDoc)
WEnd
(Didn’t check for syntax, this is from top of my head, but it should work).
HTH
Nicolas Abesdris
Quintessence e-solutions Inc.
Subject: RE: Refresh all docs in embedded view after closing form
Thank you Nicolas for the response. I’m very unfamiliar with LS. I’ve added this code to the PostSave event on the form (no syntax errors!) and when I save the form I get a “Variant does not contain an object” error. I added a statement for db (not sure if it is needed) and the code (below) is still throwing up the same vague error message.
Sub Postsave(Source As Notesuidocument)
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim view As NotesView
Set view = db.GetView ("ColorLevelCategorized")
Dim CurrentDoc As NotesDocument
Set CurrentDoc = view.GetFirstDocument
While Not CurrentDoc Is Nothing
Call CurrentDoc.ComputeWithForm (False, False)
Call CurrentDoc.Save (False, False)
Set CurrentDoc = view.GetNextDocument (CurrentDoc)
Wend
End Sub
I apologize for my ignorance with LS, but if this can function properly I would be greatly appreciative.
Thank you for your help,
Jeremy
Subject: RE: Refresh all docs in embedded view after closing form
You have to define your session handle, too.
Sub Postsave(Source As Notesuidocument)
Dim session as New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim view As NotesView
Set view = db.GetView (“ColorLevelCategorized”)
If view is nothing then
Print “Error: view not found”
Exit sub
End if
Dim CurrentDoc As NotesDocument
Set CurrentDoc = view.GetFirstDocument
While Not CurrentDoc Is Nothing
Call CurrentDoc.ComputeWithForm (False, False)
Call CurrentDoc.Save (False, False)
Set CurrentDoc = view.GetNextDocument (CurrentDoc)
Wend
End Sub
This should work.
However it will refresh ALL the documents inside the “ColorLevelCategorized” view. If you use a single category view, it is possible to refresh only the required documents from the view; but it will take a bit more coding. (You would need to use a GetAllDocumentByKey instead of a GetFirst… GetNext strategy).
Good luck!
Nicolas Abesdris
Quintessence e-solutions Inc.
Subject: RE: Refresh all docs in embedded view after closing form
It works absolutely beautifully! Thank you very much for the help; it’s greatly appreciated!
Regards,
Jeremy