Disable the first run off Lotusscript And Java agents after save

If you ever created some Notes/Domino agents and seen that everytime you save them a first run is scheduled outside or ordinary schedule. This can easily be avoided. Just add this code to the top of your agent

Dim s As New NotesSession
Dim a As notesagent
Set a=s.Currentagent
If a.Hasrunsincemodified=False Then Exit sub

This will make the agent to skip it’s first run, easy way stop the Lotusscript agent of running at odd hours and perhaps sending extra emails that confuses your users. You can ofcourse implement the same functionality in an Java agent.

If you want to run the same code inside a java agent then the code looks like this

try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
        	 System.out.println("Not runned before");
        	 System.out.println("Has runned");

          // (Your code goes here)

      } catch(Exception e) {
  1. John Detterline

    Is that in the Java agentContext?

  2. Chiheb Charmiti

    Thanks very much! I think that this behavior cause many problem to many people, running an agent in the right time it’s crucial in some cases.

  3. Server Notes.ini Amgr_SkipPriorDailyScheduledRuns=1

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.