Run schedule agent on specific view

I need to have a agent run on documents in a view at night to update them and send an email to Supervisors.

I currently have written this:

Sub Initialize
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim view As NotesView
      Dim doc As NotesDocument
      Dim agent As NotesAgent
      Set db = s.CurrentDatabase
      Set view = db.GetView( "lkupPendingRequests")
      Set agent = db.GetAgent("Supervisor")
End Sub

I feel that I am missing something to actually kick off the agent. When I run the agent Supervisor manually it works but when run it scheduled, it will not run. Any ideas?
Who is Participating?
olaraakConnect With a Mentor Commented:
Think you just miss the last row, to run agent after you got it:


This function returns Integer; 0=success

it can be used like:

If Agent.Run()=0 Then
   Print "Agent ""Supervisor"" ran successfully"
  Print "Some kind of error occurred"
End If

On the other hand,

1.  the agent Supervisor trigger can be changed to schedule
2. it would be simpler  to use Simple actions in one agent to run another
3. or use @Command( [RunAgent] ; "Supervisor ") instead of LotusSript

But yes, the Agent.Run() should also do.
You need to execute the agent as scheduled, , and have it get the documents/ view. Why do you need two separate processes ?

I hope this helps !
Oh, and if your view- processing code is in agent Supervisor, then there is no need to get the view or document before starting mentioned agent.

Or did I misunderstood something?
kali958Author Commented:
I do not want to run the agent on all the documents in the database.

I have a selection on the view that if the ContactName != Supervisor, I want to send a email notification to the Supervisor so they can approve the request.

So I thought, I would create the view, create the agent, and then schedule the agent to run at 1:00 AM on the that view but not all the documents. Am I missing something or is there a easier way?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.