Can we validate a rich-text field in Lotus Domino to only have doclinks?
Not directly, but you can control what gets into the rich-text field to begin with. In Lotus Domino R6 you can create a "Rich Text Light" field that only accepts doclinks. In Lotus Domino R5, you could use a hide-when formula to conceal your rich-text field and provide a button for adding doclinks to it using the LotusScript "AppendDocLink" method of NotesRichTextItem. If the Lotus Notes user has no other way to put anything is the field, it can only contain doclinks.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
The trouble with validating what's already in the field is that the only programmatic way to see what's in the field is to call NotesRichTextItem's "GetFormattedText" method. Depending on your situation, this might be sufficient, but it won't let you detect images or other rich-text content.
You might be able to get somewhere by using the DXLExporter to dump the Lotus Notes document to XML and then parse through it for the field in question. If that doesn't work, there's always the Midas Rich Text Toolkit from GenniSoft.
Part of Cregg Hardwick's response was: "In Lotus Domino R6 you can create a 'Rich Text Light' field that only accepts doclinks."
Maybe I'm missing something, but I don't see doclinks as one of the choices in a Rich Text Light field, nor would I equate any of the available choices to being doclinks. Am I missing something?
I was wrong. It is not possible to place a doclink in a "Rich Text Light" field. The rest of my comments are still valid though. The best approach is to control what gets into the field in the first place, by only allowing programmatic updates to the rich-text field. The RichTextItem class has methods for adding any kind of Lotus Notes doclink.
Once you have extant data that you want to validate, however, it gets much harder. I think the best bet is to dump the document in question to XML -- using the DXLexport, and parse the resulting file to find the rich-text field. I have not tried this specifically, but I believe DXL now has full support for rich-text content -- in Lotus Domino R5 it did not. Unfortunately, I don't have time to work through this, and using the DXL functions are non-trivial. So depending on the application, this might or might not be practical.
Cregg Hardwick, LotusScript Expert
Do you have comments on this Ask the Expert Q&A? Let us know.
Related information from SearchDomino.com:
Dig Deeper on LotusScript
Related Q&A from Cregg Hardwick
A user wants to know if it's possible for LotusScript to read an attachment in a Notes document without first detaching it. Find out our expert's ...continue reading
Learn about different options using LotusScript code and Formula language to customize the principal field of outgoing Lotus Notes email messages.continue reading
Read about merging cells in a Microsoft Word table using LotusScript and an Excel example, along with the thought process that goes along with it.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.