Hi Forum,
my code (it is action button) crashes client - any suggestion?:
Dim s As New NotesSession
Dim ndoc As NotesDocument
Dim doc As NotesDocument
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim uidoc2 As NotesUIDocument
Dim tmp
Set uidoc = ws.CurrentDocument
Set doc = ws.CurrentDocument.Document
Set tmp = doc.GetFirstItem( {docid} )
If uidoc.EditMode Then
call uidoc.Save()
End If
Set ndoc = s.CurrentDatabase.CreateDocument
Call ndoc.ReplaceItemValue( {form}, {Attachment} )
Call ndoc.ReplaceItemValue( {ParentID}, tmp )
Call ndoc.ReplaceItemValue( {AllowOpen}, 1 )
Print {new doc is opening}
Set uidoc2 = ws.EditDocument( True, ndoc )
Call uidoc.Close( True )
Thank you !
Subject: Re: notesuidocument.Close(True) crashes client
How do you know that’s the statement causing the crash?Do you need the True argument? What if you left it off, does it still crash?
What’s the crash stack in the NSD?
Did you contact Lotus Support?
Subject: Suggestions
I have found the following to be the best practice when calling uidoc.Close(True) so as to prevent any issues with it:
-
After you have saved any changes but just before closing the document call doc.ReplaceItemValue(“SaveOptions”, “0”). This insures that it will close even if there is some frontend validation that would take place or some other process modified the document since you saved it.
-
Immediatelly after the call to uidoc.Close(True) call “Delete uidoc”. This just releases any handle to the object - and doesn’t physically delete the document.
-
Do the above BEFORE making a call to open another document in the UI (so make your call to set uidoc2 after closing uidoc).