次の LotusScript エージェントは JavaScript をブラウザに送信することで終了します。JavaScript はメッセージを表示し、次に「Main View」をロードします。Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim arg As String, p1 As Long
arg = s.DocumentContext.Query_String(0)
p1 = Instr(arg, "&")
If p1 = 0 Then
Print "Need argument 'Open' or 'Closed'"
Exit Sub
Else
arg = Lcase(Mid$(arg, p1 + 1))
If arg <> "open" And arg <> "closed" Then
Print "Argument must be 'Open' or 'Closed'"
Exit Sub
End If
End If
arg = Ucase(Left$(arg, 1)) + Right$(arg, Len(arg) - 1)
Set db = s.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
Do While Not(doc Is Nothing)
doc.Status = arg
Call doc.Save(False, True)
Set doc = dc.GetNextDocument(doc)
Loop
Print "<SCRIPT LANGUAGE=JavaScript>"
Print "alert(""Status changed to '" & arg & _
"' in all documents"")"
Print "location.href = ""/Web+test.nsf/Main+View?OpenView"""
Print "</SCRIPT>"
End Sub
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim context As NotesDocument
Dim arg As String
Set context = s.DocumentContext
arg = s.DocumentContext.Query_String(0)
p1 = Instr(arg, "&")
If p1 = 0 Then
Print "Need argument 'open' or 'closed'"
Else
arg = Lcase(Mid$(arg, p1 + 1))
If arg <> "open" And arg <> "closed" Then
Print "Argument must be 'open' or 'closed'"
End If
End If
Set db = s.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
Do While Not(doc Is Nothing)
doc.Status = arg
Call doc.Save(False, True)
Set doc = dc.GetNextDocument(doc)
Loop
Print "<SCRIPT LANGUAGE=JavaScript>"
Print "alert(""Status changed to '" & arg & _
"' in all documents"")"
Print "location.href = ""/Web+test.nsf/Main+View?OpenView"""
Print "</SCRIPT>"
End Sub