Desperately need help with rich text editing

I know this subject has been addressed in other topics, but I just can’t get my code to work and am getting very frustrated - I’ve been working on this one issue for over a week now!

Patrick Montavon posted an excellent piece of code in repsponse to an earlier question of mine about editing rich text (http://www-10.lotus.com/ldd/nd6forum.nsf/ShowMyTopicsAllFlatweb/3b8122ecfe141e9885256fac005158b4?OpenDocument), but the problem is that, while it works in the button code he posted, it doesn’t work with the QuerySave event.

Here’s what I’m attempting to do:

  1. The user makes some changes to a document, and possibly adds some notes.

  2. On Save, I want to log those changes to a computed rich text history field, and add the notes as well, clearing the notes field.

Seems simple, doesn’t it? I want to use rich text because the users want formatting capabilities for their notes, and because these history fields can get quite big. Currently I use a plain text field which I have to periodically save off as a text file and attach it to the document as old history. This is a lame workaround for something that should be so simple and rich text has no limit in size.

When I use a button to call my UpdateHistory code, all behaves well. But when I call the code from QuerySave, the history field gets updated (and shows on screen) but never written to disk. I’ve even tried doing a second doc.save in the PostSave event but still no history save happens. The other fields on the form are saved however. If I do a manual second save on the form, the first history change gets saved.

Here’s another quirk: after doing the save which calls the updatehistory routine, which closes and reopens the ui doc and then removes the saveoptions field, the saveoptions field is still there! I’m sure that has something to do with this, but I can step through the code in debug and see the line “Call doc.Removeitem(“SaveOptions”)” get executed, but the field is still there if I look at the document properties box!

Does anyone have any ideas that would help me? This is driving me batty. Okay, battier.

Frustrated in San Francisco,

Beth

Subject: Desperately need help with rich text editing

O-tay…

You absolutely cannot do what you want to do during the QuerySave event. You’ve run into a collision that can’t really be avoided – user changes to Rich Text (their notes) have to be saved via a UI document save in order to make it from the editor into the rich text field (the two have almost an appication/file relationship). At the same time, you want to create changes in the back end to a rich text field. Guess what? Your changes won’t happen if their is a UI save, so you have to set a SaveOPtions to “0” and close the UI doc to save in the back end. Ah, but the user changes won’t get saved now…

Let the UI save proceed as normal, then in the PostSave, set your SaveOptions field, close the document, update the back-end, then re-open the document. That way your user changes get saved to the RT field, and you can still add your own changes.

Subject: RE: Desperately need help with rich text editing

Sounds like a good suggestion! I’ll try it and report back.

Thanks :slight_smile:

Beth

Subject: RE: Desperately need help with rich text editing

Okay! Very close. I moved the update history call to PostSave and that appears to work very well EXCEPT if the user clicks on the “x” to close the window and is prompted to save and says yes, everything saves correctly but the window does not close. You have to click the x again to close.

I think this is due to the fact that a different UI window was opened, and I will look into ways to figure that out tomorrow.

Cheers and thanks for a great and quick response .

Beth