Adding/Displaying Doc Links in a RichText Field

I’m trying to provide an easy way to select a group of documents to send out based on a category. I would like to be able to associate document links with the various categories. I’ve created a form that has a Category Field (Text) and a document links field (RichText). I have a button that brings up a dialog box that contains an embedded view of the documents I want to link to. I’d like the user to be able to select the documents, click ok and have the document links to those documents added to the RichText field and have it display there. I’ve been experimenting with this and have found that I need some education in this area. Could someone make some suggestions as to how I might accomplish this. I’ve done a little programming with the NotesRichTextItem, but I get lost when trying to get what I’ve added to the field to display immediately. I haven’t found a good explanation in the 4 reference books I have and I’ve browsed this site extensively and have only gleened pieces of the explanation. If one of you gurus could explain this whole RichText / doclink / display it thing to me, I would be forever in your debt.

Thanks,

MJ

Subject: Adding/Displaying Doc Links in a RichText Field

  • Rich text in Notes is about as arcane as it gets, short of the C++ API. Because of this, you’ll have to play with it until it works how you want it to.-

  • First, you can’t get RT to display without closing the UI document and reloading it from the back-end document. The most consistent process I’ve found is to close the UI document, save the changes to the back-end document, then recreate the UI document from that back-end. There are methods in LotusScript to do all this.

  • Second, you can’t just make the RT field multi-value and add stuff to it. You have to manually manage every aspect of it, and some of that management requires a lot of hoop-jumping. As long as you are adding default text and embedding objects, it’s fairly straightforward. Look at the AppendText, AddNewline, and AppendDoclink methods of NotesRichTextItem. If you want to change fonts, colors, or add tables, you’re going to have to do four times as much work as you’d expect, but it’s all right there in the Help file.

  • None of this addresses how to acquire the doclinks. I presume you have a View by Category that you can use to just look them up … it’s the Notes RT end that’s the snag.

  • Hope this helps…

Subject: RE: Adding/Displaying Doc Links in a RichText Field

Thanks, Dave. I appreciate the help. I have a couple of things working using RT fields and have done some things with the NotesRichTextNavigator, but the part that was really confusing to me was the close and open process. I’ll try what you suggested. Too bad, Lotus didn’t have an easier way to do this. Seems to me to be a very desirable action for many different applications.

Have you seen any of the sample apps or sandbox apps that do anything close to this?

thanks again,

MJ

Subject: Adding/Displaying Doc Links in a RichText Field

When you open a document in the user interface, there are three copies of the information. One is in the NSF file. Another is in menory. The third is in the UI editor. All three copies contain essentially the same data, but in different formats.When you use LotusScript to work with a document, you are working on the in-memory copy. Notes can automatically reflect changes between the in-memory copy and the editor copy, except in the case of Rich Text. This is a limitation of the editor.

When you work with a NotesRichText item, you are working with a fourth copy of the Rich Text data. The Update method saves your changes to the in-memory copy of the document. (Before Notes 6 you had to save the document, updating the NSF copy of the document too, whether you wanted that or not.)

If you use LotusScript to add links to Rich Text in memory, then you have to close the editor copy of the document and open it again to get your change displayed. Use uidoc.Close(True) and workspace.EditDocument to close and open the document in the editor.

If the editor saves its Rich Text, then it will overwrite the changes you have just made in memory. You can use a SaveOptions field containing “0” to stop the editor saving anything.