- 従業員が要求を入力します。[Owner] フィールドの値が「Employee」のとき、従業員は要求内容を示す文字列の入力を求められます。[Owner] フィールドの値が「Manager」に変わると文書は保存され、終了します。
- 管理者がこの要求を承認するか却下します。[Owner] フィールドの値が「Manager」のとき、[はい] と [いいえ] ボタンがあるダイアログボックスが表示されて、要求を承認するかどうかが確認されます。[Status] フィールドは「Approved」または「Rejected」に設定され、[Owner] フィールドは「Human Resources」に変更されます。文書は保存され、終了します。
- 人事担当者が管理者の決定を承認するか却下します。[Owner] フィールドの値が「Human Resources」のとき、[はい] と [いいえ] ボタンがあるダイアログボックスが表示されて、管理者の決定を承認するかどうかが確認されます。どちらかが選択されると、[Confirmation] フィールドが「Approved」または「Rejected」に設定され、文書は保存され、終了します。
このスクリプトが実行されるには、ファイル LSCONST.LSS をインクルードしなければなりません。
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