URGENT! Scheduled agen run but cannot loop document in view

Dear experts,…

I have problem in scheduled agent in domino R7.

it seem like loop is not working

While Not cdoc Is Nothing

Set maildoc = New NotesDocument (db)

Set Cdoc = view.GetnextDocument(Cdoc)

Wend

but loop will run if i run manually from notes client

but if i run as scheduled agent, the loop is not works,

Anybody know what’s wrong with my simple coding as below ?

agent also sign by server ID

'==================================

On Error Goto label

Dim db As NotesDatabase

Dim session As New NotesSession

Set db = session.Currentdatabase

Dim view As NotesView

Set view= db.GetView (“sampleview”)

Dim Cdoc As NotesDocument

Set Cdoc = view.GetFirstDocument

While Not cdoc Is Nothing

'=====notification loop run or not

Set maildoc = New NotesDocument (db)

maildoc.form=“Memo”

maildoc.sendto=“userxxx”

maildoc.subject="loop run "

Call maildoc.send(False)

Set Cdoc = view.GetnextDocument(Cdoc)

Wend

'======= notification if agen run

Set maildoc = New NotesDocument (db)

maildoc.form=“Memo”

maildoc.sendto=“userxxx”

maildoc.subject=“agen run”

Call maildoc.send(False)

End

label:

'notification if agen error

Set maildoc = New NotesDocument (db)

maildoc.form=“Memo”

maildoc.sendto=“userxxx”

maildoc.subject=“agent error”

Call maildoc.send(False)

'========================

Subject: URGENT!! Scheduled agen run but cannot loop document in view

Hi What do you have as target (agent properties->runtime, Target)?

It should be all documents in database.

And a probably silly thing; do you have any documents in the view??

Does it work when you write

tell amgr run “testDB.nsf” ‘testAgent’

?

Good luck

Subject: RE: URGENT!! Scheduled agen run but cannot loop document in view

Sure, i set target is all document in database, and many document in view,If i run from domino console, actually the agent is running, but it always skip the loop,.

I can receive notification “agen run”

but always not received notification "loop run "

it seem’s like agent skip my below loop

While Not cdoc Is Nothing

'=====notification loop run or not

Set maildoc = New NotesDocument (db)

maildoc.form=“Memo”

maildoc.sendto=“userxxx”

maildoc.subject="loop run "

Call maildoc.send(False)

Set Cdoc = view.GetnextDocument(Cdoc)

Wend

But if i run it manually, it’s working fine

Subject: RE: URGENT!! Scheduled agen run but cannot loop document in view

Make sure you’ve got both a default form and a default view in your database. This can often stop scheduled agents from running as expected.

Also have a look at the Agent FAQ (use the Forum FAQs link on the right had side) for other ideas.

Emily.

Subject: URGENT!! Scheduled agen run but cannot loop document in view

Chances are this is an issue with your Agent settings more so than with your code. At first glance, the code looks fine.

If your code runs manually, this is a pretty good indication that the issue is what I just mentioned here above.

regards,

rb