Agent works in client, runs but no effect on server

I have already gotten one good answer here to assist with my lack of general admin knowledge, maybe I will be two for two today. I have a very basic agent that goes through a view and sets some values in documents and saves them. It works as expected if run from the action menu in the client, but if I switch it to scheduled, it runs but the documents do not get modified. I am baffled. Also, despite my agent log statements, I am not able to write out lines to the agent log using logaction. They just don’t show up. Any clues? Thanks in advance.

Subject: Agent works in client, runs but no effect on server

Suggestion: before you do anything else but as soon as you initialize the agent log, write a line to it.

Also, close the log in the Terminate sub (making sure that the log has been opened first, of course) - this way the log will always get closed even if an error causes the code to skip over the place where you are currently closing the log.

Subject: Agent works in client, runs but no effect on server

and posting your code for us to look at might help too.

Subject: RE: Agent works in client, runs but no effect on server

This is pretty basic, which is why I am baffled. It will run on the server, but nothing happens in the documents and the log is just the default start/stop times. If run from the client, the documents are updated but still no log entries. Thanks for looking.

All variables are declared, then

On Error Goto processError

Call agentLog.OpenAgentLog

Call agentLog.LogAction(“Updating Defect Ages”)

Set Db = Session.CurrentDatabase

Set View = Db.GetView(“AllDefectsReport”)

count=view.EntryCount

Set Doc = View.getfirstdocument

Do While Not(Doc Is Nothing)

Set timedefopen = New NotesDateTime(doc.DefectDate(0))

		diff = timenow.TimeDifference(timedefopen)/86400

		doc.DefectAge = diff

		Call doc.Save(True,False,True)

		k=k+1

		'Print "Setting age for Defect " & Cstr(k) & " of " & count

	Set Doc = View.getnextdocument(Doc)

Loop



Call agentLog.LogAction("Defect Ages Set")

Call agentLog.Close

Exit Sub

processError:

Call agentLog.LogAction("Error" & Err() & ": " & Error())

Call agentLog.Close

'Print "Set Defect Age Error.  See Agent Log"

Exit Sub

Subject: RE: Agent works in client, runs but no effect on server

OK, the fact that you have no log entries in either the server or client leads me to believe that your log is not actually open. When you say:

“All variables are declared”

do you mean:

Dim agentLog as NotesLog

or do you mean:

Dim agentLog as New NotesLog(“My simple agent”)

If the first, what is happening is that you try to call the OpenAgentLog on an object that is still set to Nothing. This, of course fails, and is caught by the processError handler but the error trapping doesn’t help you because it still can’t write to the log.

Is this the case?

Subject: RE: Agent works in client, runs but no effect on server

try printing your error instead of writing it to your log, perhaps the problem is prior to your agent log being opened which may be why no error gets logged to it.

Subject: RE: Agent works in client, runs but no effect on server

The real issue here is why does it work one way in the client and one way on the server. If I run the agent in the client, it works 100% as expected, log and all. When I switch it to scheduled, nothing happens and no log. If I remove all of the agent log stuff, still no changes to my documents. I feel like this is some sort of security thing or something. Is there any sort of way that I could have rights to run the agent, but not have rights to do a log on the server or edit documents? I am not able to even look at the server doc and the person from whom I must request changes to it is not a Notes person so I don’t know what to tell them. They did send me a sceenshot confirming that I am in the expected fields to allow me to run all agents. Here’s hoping an admin guru speaks up…

Subject: RE: Agent works in client, runs but no effect on server

Hi Daniel,

Then you led me astray with you previous posting, where you said:

“This is pretty basic, which is why I am baffled. It will run on the server, but nothing happens in the documents and the log is just the default start/stop times. If run from the client, the documents are updated but still no log entries. Thanks for looking.”

implying that even when run from the client, there were no log entries. So, just to make sure, you do have log entries when running from the client?

Also, please post the entire code (incl. declarations) - it may be that you are declaring some NotesUI classes that would prevent the the agent from running scheduled.

Subject: RE: Agent works in client, runs but no effect on server

I was going to post the code, but your comment about UI declarations made me check, and sure enough I declared the UI Workspace (a result of cutting/pasting this code from a form event to an agent). Of course it was not needed and when I removed it the agent worked on the server as expected! Thank you so much for paying attention to this thread. You made my day and I learned a valuable lesson!

Subject: No problem whatsoever