Selective Printing Of Status MessagesMany times we have agents that run both in the foreground and in the background. For example, if there's an agent that does some weekly processing we may want to run it during the week manually. When we run it in the foreground, we want to include print statements to update on the progress. But those are unnecessary when running in the background. How do we selectively decide when to print progress statements?
This is surprisingly simple. There's a property of the NotesSession class called IsOnServer. When the server is running the agent on its schedule, this value will be True. When a client is running the same agent, this value will be False. So our progress print statements look something like this:
If Not session.IsOnServer Then Print "Processing... Determining current access..."
Of course, you decide what you want to print. But when the agent is being run on a schedule, nothing will be printed. The message will only be printed when the client is running the agent.