Error creating product object

Hi,

I have the following problem:

An agent in a mail in database should cleanup the database once a day and keap the latest document of all senders. I built a view where documents are sorted by posted date/time for cleanup. Here’s the code of my periodic agent:

Dim s As New NotesSession

Dim db As NotesDatabase

Dim ws As New NotesUIWorkspace

Dim doc, doc2 As notesdocument

Dim v As notesview



Set db = s.CurrentDatabase

Set v = db.GetView("cleanupview")



Set doc = v.GetFirstDocument

Set doc2 = v.GetNextDocument(doc)



Do While Not doc2 Is Nothing

	If doc2.from(0) = doc.from(0) Then Call doc.remove(True)		

	Set doc=doc2

	Set doc2= v.getnextdocument(doc)

Loop

THe problem is, that it works on the client but not on server. I always get the console error:

“Agent ‘Cleanup’ error: Error creating product object”

I tried different agent triggers, granted each kind of access, signed the agent, ran it on behalf of me,… Nothing I could do. What am I doing wrong? Any Ideas?

Cheers René

Subject: Error creating product object

Remove the “Dim ws As New NotesUIWorkspace” line; you don’t use “ws” anyway.

UI stuff doesn’t work in agents. That is probably the cause of the problem.

I wrote “probably” because I thought that in Notes6, the agent manager would just skip UI declarations.

Subject: Thanks…

Yes, thanks. That was what I 've been doing wrong. I have a standard snippet for my declarations and I always delete the lines I don’t need. This time there was one I forgot. (Sometimes you can’t see the forest for the trees) :wink:

Thanks a lot,

René