|
|
ShowTable of Contents
I had to write a small maintenance agent to reset NotesItems, and, to not accidentally trigger it, I used the @Prompt function to ask the typical "Are you really sure?" question - not a good idea ;-) The result was, that I had to keep clicking message boxes until the agent was finally done - fortunately there where only 42 documents in the databases, which made me click 42 times. Here is why; I used the following agent, with the options "Action menu selection" and "All selected documents": @If(!@Prompt([YesNo]; "Reset fields"; "Are you sure?"); @Return(""); "");
@SetField("Body"; "");
@SetField("nbMemos"; 0);
[...]
SELECT @All
If you do this, the result is, that Notes triggers the agent for each document (actually "of course" ;-)) and asks for each document separately; could be kind of useful if this is what you want it to do, but you should never try this on a database storing some thousand documents :-)
A better way to accomplish the task would be to write the agent in LotusScript, even though it is a lot longer:
'RESET MAIL FIELDS:
Option Public
Option Declare
%INCLUDE "lsconst.lss"
Sub Initialize
On Error Goto errorhandler
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Dim doccoll As NotesDocumentCollection
Set doccoll = db.UnprocessedDocuments
If doccoll Is Nothing Then
Exit Sub
End If
If Msgbox("Are you sure?", MB_YESNO, "Reset fields") <> IDYES Then
Exit Sub
End If
Call doccoll.StampAll("Body", "")
Call doccoll.StampAll("nbMemos", 0)
[...]
e:
Exit Sub
errorhandler:
Msgbox "Error " & Error & " in line " & Erl
Resume e
End Sub
|