APPLICATION DESIGN


Examples: Creating an event script or formula
Displaying a message when users close a document

The following QueryClose event script for a form displays a message when users close a document they’ve edited:

Sub QueryClose(Source As Notesuidocument,ContinueAsVariant
  Dim workspace As New NotesUIWorkspace
  Dim doc as NotesUIDocument
  Set doc = workspace.CurrentDocument
  If doc.EditMode Then
     Messagebox("Call Pat at x-314 if you have any questions.")
  End If
End Sub

Filling in fields automatically

The following script for a field Entering event fills in the FullName field by concatenating the FirstName field, a space, and the LastName field:

Sub Entering(Source As Field)
  Dim workspace As New NotesUIWorkspace
  Set doc = workspace.CurrentDocument
  firstName = doc.FieldGetText("FirstName")
  lastName = doc.FieldGetText("LastName")
  fullName = firstName & " " & lastName
  Call doc.FieldSetText("FullName", fullName)
End Sub

Requiring a field to be filled in

The following script for a field Exiting event requires users to fill in a LastName field after they fill in the FirstName field:

Sub Exiting
  Dim W As New NotesUIWorkspace
  Dim UIDoc As NotesUIDocument
  Set UIDoc = W.CurrentDocument
  If (UIDoc.FieldGetText ("LastName") <> "") Then
    UIDoc.GotoField "FirstName"
  Else
    UIDoc.GotoField "LastName"
   Messagebox "You must enter the person’s last name.", 0, "ERROR"
 End If
End Sub

See Also