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();
if(agentContext.getCurrentAgent().getLastRun()==null){
System.out.println("Not runned before");
}else{
System.out.println("Has runned");
}
// (Your code goes here)
} catch(Exception e) {
e.printStackTrace();
}
Is that in the Java agentContext?
The first example is for a Lotusscript agent, will add an java example also.
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.
Server Notes.ini Amgr_SkipPriorDailyScheduledRuns=1