I have a simple agent that doesn’t work… please tell me if I’ve gone astray…
Scheduled to run every hour (I’d settle for once a day if even that would work)
Scheduled to run on ALL Documents in the DB
Code:
dt:=@Today;
@If(EventDate < dt;@SetField(“flag”;“Yes”); @SetField(“flag”;“No”))
All I want it to do is check each document on a daily basis… and once EventDate is yesterday… Flag it as Yes.
Sounds simple…
?
The code wrks fine if I put it in a manual Button… it’s just not running as an agent.
The agent Log says it ran… found 9 document and updated 9 documents… NOPE … it didn’t.
Ruth
Subject: Perhaps you should try: (and you really only need to run it once a day)
Same trigger but this also stops unneeded modifications to every document in the database.
SELECT (EventDate < @Today) & (flag = “No” : “”)
FIELD flag := “Yes”;
Subject: Am I expecting too much from an agent?
I know that some people have problems with using dates in view selections, but as long as the view is back-end and not being accessed visibly by the users, I’ve not had any problems.
Why not just create a new view that contains all documents whose EventDate=@Yesterday? Then you can set the agent to run once a day on all documents in that view. It might be easier to debug using LotusScript; a simple agent to do what you want would look like this:
Sub Initialize
on error goto errhand
Dim session As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim dView As NotesView
Set db = session.currentdatabase
Set dView=db.GetView("yourView")
Set doc = dView.GetFirstDocument
Do While Not (doc Is Nothing)
doc.flag = "Yes"
Call doc.Save(True, False)
Set doc = dView.GetNextDocument(doc)
Loop
errhand:
Print "error at line " & erl & ": " & error
Exit sub
End Sub
Another possibility occurs if you have Readers fields on your documents - if your name is in the Readers fields but the server is not (whether on its own or via a role), it will allow you to run the agent manually, but the server will not be able to update the documents. Same issue with Authors fields, if the server is not listed in the ACL as manager.