例: Run method

  1. 次のエージェントは、下の「Agent to be run LotusScript®」エージェントを実行します。
    Sub Initialize
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim agent As NotesAgent
      Set db = s.CurrentDatabase
      Set agent = db.GetAgent("Agent to be run LotusScript")
      If agent.Run = 0 Then
        Messagebox "Agent ran",, "Success"
      Else
        Messagebox "Agent did not run",, "Failure"
      End If
    End Sub

    「Agent to be run LotusScript」エージェント

    Sub Initialize
      Dim s As New NotesSession
      Dim agent As NotesAgent
      Set agent = s.CurrentAgent
      Dim db As NotesDatabase
      Set db = s.CurrentDatabase
      Dim memo As New NotesDocument(db)
      memo.Form = "Memo"
      memo.SendTo = s.UserName
      memo.Subject = "Message from LotusScript agent"
      memo.Body = "The agent is running as " & s.UserName
      Call memo.Send(False)
    End Sub
  2. 次のエージェントは「Agent to be run parameter LotusScript」というエージェントを実行し、新規に作成した文書の文書 ID を渡します。
    Sub Initialize
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim agent As NotesAgent
      Set db = s.CurrentDatabase
      REM Create document containing data to be passed
      Set doc = New NotesDocument(db)
      doc.TriggerUserName = s.UserName
      Call doc.Save(True, False)
      REM Start agent and pass note ID of document
      Set agent = _
      db.GetAgent("Agent to be run parameter LotusScript")
      If agent.Run(doc.NoteID) = 0 Then
        Messagebox "Agent ran",, "Success"
      Else
        Messagebox "Agent did not run",, "Failure"
      End If
    End Sub

    「Agent to be run parameter LotusScript」エージェント。このエージェントは ParameterDocID を通して渡された文書 ID にアクセスし、参照文書にアクセスし、その文書を削除します。

    Sub Initialize
      Dim s As New NotesSession
      Dim agent As NotesAgent
      Set agent = s.CurrentAgent
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Set db = s.CurrentDatabase
      REM Get document used for passing data
      Set doc = db.GetDocumentByID(agent.ParameterDocID)
      REM Send mail containing passed data
      Dim memo As New NotesDocument(db)
      memo.Form = "Memo"
      memo.SendTo = s.UserName
      memo.Subject = "Message from LotusScript agent"
      memo.Body = "The agent was started by " _
      & doc.TriggerUserName(0)
      Call memo.Send(False)
      REM Delete document used for passing data
      Call doc.Remove(True)
    End Sub