Change Document to Edit Mode
Using a subroutine, you can change the state of the current document (as displayed in the user interface) to either read-only or edit mode. This solution is handy if you have buttons that update fields using the user interface and the document must be in edit mode, or if you want to change the document state after performing a change. This approach provides a user-friendly implementation. The document is automatically switched to edit mode prior to setting values on the document.
How It Works
The document state is changed based on the Boolean value passed to the SetEditMode subroutine. Passing a trUE value will open the document in edit mode. Passing a FALSE value will set the document to read-only mode. Using the EditDocument method, the subroutine toggles between document states.
Implementation
This routine can only be implemented when documents are accessed from the front-end. Pass a trUE or FALSE parameter to the LotusScript subroutine, and the document edit mode will change accordingly. Place the following in a LotusScript library.
Sub SetEditMode (value as Boolean) Dim w As NotesUIWorkspace Set w = New NotesUIWorkspace If (value = True) or (value = False) Then Call w.EditDocument(value) Else msgbox "Invalid parameter passed to SetEditMode subroutine." End If End Sub
The following code illustrates how to call the subroutine to change the document into edit mode. When the document is in edit mode, you can insert additional code to continue with application processing.
Sub Click(Source As Button) Call SetEditMode (True) REM continue with processing End Sub
Note
Remember to include the Use LIBRARY statement (where LIBRARY represents the name of the LotusScript library) if adding this subroutine to a shared library. Otherwise, you will receive an error when attempting to save the design element. No Use statement is required if the subroutine is included in the current design element.