RE: Schedule Agent Karl-Henry Martinsson 7.Mar.16 01:50 PM a Web browser Domino Designer All ReleasesAll Platforms
1) Instead of "while not doc is nothing", use "do until doc is nothing", it makes it easier to read the code.
2) Don't use extended notation when you access fields on a document. Use the GetItemValue/ReplaceItemValue methods of the NotesDocument class instead, better performance as well as making the application forward compatible.
3) You are processing all documents and updating every single document. Only update the ones where the value changed.
4) You have a very weird construction in your loop:
Else If (without a statement!)
That won't work, should not even be accepted by the editor.
5) To make the agent faster, don't loop though the view and read every single document. This is a very "expensive" call. Instead you should get a NotesViewEntryCollection and loop through the view entries. Make sure you display the field value you want to compare with (e.g. DaysConsumed and ClaimedBy) in the view, then use the ColumnValues peroperty of the NotesViewEntry class to get read the values. Then only open and update the document if the value has changed.