Replace a string in the documents in a Lotus database

I think it might be useful to replace each occurrence of a string in all the documents or in the selected documents in a Lotus database, especially when you want to replace a user in the fields author/reader.
The use of roles or groups should be recommended to set the access to the documents, but there may be cases where the user’s name has been used as in Lotus Workflow projects.

This code only works for fields of type text, number, name, author, reader and date.

The meaning of the constants in the code:

  • ONLYSELECTEDDOCUMENTS : True to process only selected documents, False to process all documents in the database
  • FROMSTRING : string to replace
  • TOSTRING : new string
  • WHOLE_WORD : True if you want to replace only if the field or a its element in the case of multivalue field is exactly equal to FROMSTRING, False if you want to replace even if the string FROMSTRING is a substring of field or a its element in the case of multivalue field
  • EXCLUDEDOLLARFIELDS : True to exclude fields whose names begin with “$” symbol like $Revisions or $UpdatedBy, False to include these fields
  • EXCLUDEFIELDS : list of fields not to be replaced in the format of “Field1;Field2;Field3”
  • INCLUDEONLYFIELDS : list of fields only to be replaced in the format of “Field1;Field2;Field3”

Below there is the code to insert in a LotusScript agent, tested on Lotus Notes 8.5.2

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.