Error creating product object

‘Error creating product object’ was the error message in a scheduled LotusScript Agent. If the agent was started manually it just works. The colleague who developed the agent was ill, so I had a little 911 work on a live system. I added a few print statements to the code but the agent started and stopped immediately without any statement in the console.
My fault was that I didn’t look a the very first rows of the Dim statements. The second row was ‘Dim ws as new NotesUIWorkspace’. Uh, my old friend, this will never work in a scheduled agent.
I thought my work was done but the agent stopped again after 1000 documents of about 100.000 documents in the view.
OK. I had a closer look. The agent looped through the documents by ‘view.GetNextDocument(document)’. In the loop a item of the current document was changed but this item was used as a view selection criteria. There again, my old friend, this will never work correct. So I changed the agent to loop through the documents by ‘view.GetNthDocument(index)’ and increased the index variable in the loop.
Now the agent runs fine and puts the attachments of notesdocuments in the IBM CommonStore for Lotus Notes archive.
What a friday morning…