HiI have form in whcih I have field called “comments” of type rich text.There are several documents created with this form. Now i have to replace a string in this comments field with another. As there are 100’s of documents manual work is difficult. So i tried an agent with @ReplaceSubString and @Replace but no luck. Not sure what I missed.
Subject: RE: How to replace a specific string in Rich text field with another string
The field type in my case is “Rich text”.Not sure whether these functions work with rich text or not. I tried extracting text from rich text and then try replace but still no luck.
Subject: RE: How to replace a specific string in Rich text field with another string
I think the problem is with RT. Now I did see the error message in field value : “Text expected”. If I change the field as Text then its working. So not sure how i can i achieve with RT.
Subject: RE: How to replace a specific string in Rich text field with another string
Accessing and modifying rich text is a little more complex than that. Probably the easiest method to use for a one-time operation is to export the documents to a NotesStream using DXL, reading the stream text into a string, then using Replace against the string, writing the string to a NotesStream and re-importing the DXL (in LotusScript).
The LotusScript documentation you’ll need can be found in:
NotesNoteCollection
NotesDXLExporter
NotesStream
Replace
NotesDXLImporter
The examples in the NotesNoteCollection, NotesDXLExporter and NotesDXLImporter are clear and should make the process fairly easy.
Note: if the phrase to be replaced shows up in a bunch of places that it shouldn’t be replaced as well as in the rich text fields, you’ll proably want to export to a NotesDomParser and use standard DOM Level 3 methods in conjunction with Replace in order to ensure that you are only changing the elements you want to change.
Subject: RE: How to replace a specific string in Rich text field with another string
You know – you’re right. However, it has its limitations (like its inability to deal with hotspots and so on). There are enough problems with the native rich text methods that I almost never think to use any of them – DXL is at least as easy and much more versatile.