- The employee enters the request. If the Owner field contains "Employee," the script prompts the employee for the text of the request. The Owner field is changed to "Manager," and the document is saved and closed.
 - The manager approves or rejects the request. If the Owner field contains "Manager," the script displays a dialog box with Yes and No buttons, asking the Manager if she approves the request. The Status field gets set to either "Approved" or "Rejected," the Owner field is changed to "Human Resources," and the document is saved and closed.
 - The Human Resources person approves or rejects the Manager's decision. If the Owner field contains "Human Resources," the script displays a dialog box with Yes and No buttons, asking the Human Resources person if he approves the Manager's decision. The Confirmation field gets set to either "Approved" or "Rejected," and the document is saved and closed.
 
This script must include the file LSCONST.LSS in order to work properly.
Sub Postopen(Source As Notesuidocument)
  Dim ownerType As String
  Dim employeeRequest As String
  Dim result As Integer
  If source.EditMode Then
    ownerType = source.FieldGetText( "Owner" )
    Select Case ownerType
    ' 1. Employee enters the request in a dialog box
    Case "Employee":
      employeeRequest = Inputbox$ _
      ( "Please enter your request", "Request" )
      Call source.FieldSetText("Request", employeeRequest)
      Call source.FieldSetText("Owner", "Manager")
               
     ' 2. Manager approves or rejects the request
    Case "Manager":
      result = Messagebox _
      ( "Do you approve this employee's request?", _
      MB_YESNO, "Approve" )
      If ( result = IDYES ) Then
        Call source.FieldSetText( "Status", "Approved" )
      Else
        Call source.FieldSetText( "Status", "Rejected" )
      End If
      Call source.FieldSetText("Owner", "Human Resources")
               
    ' 3. Human Resources approves or rejects
    ' the Manager's decision
    Case "Human Resources":
      result = Messagebox _
      ( "Do you approve this manager's decision?", _
      MB_YESNO, "Confirm" )
      If ( result = IDYES ) Then
        Call source.FieldSetText _
        ( "Confirmation", "Approved" )
      Else
        Call source.FieldSetText _
        ( "Confirmation", "Rejected" )
      End If
    End Select
          
    ' After each step, the document is saved and closed
    Call source.Save
    Call source.Close
  End If
End Sub