An easier way to update a rich text field

We've all been waiting for it, but it has yet to be delivered – the ability to update a rich text field and displaying the changes to a user without having to save, close and reopen the form.

Currently, if you have a document locking enabled for the database, the traditional method of closing and reopening works. But, if you make a change to the document afterward and try to save it, a save conflict is generated. To get around this, you have to save and close the form, and create a new document to display to the user.

Here's how:

'Set db, doc & uidoc and update richtext field..........

'Display updates for user:
Dim newUIDoc As NotesUIDocument
Dim newDoc As NotesDocument
Dim oldDoc As NotesDocument
 'cannot delete doc from the ui
  
'Save Original Document:
docID$ = doc.UniversalID
doc.SaveOptions = "0" 'so users 
are not prompted to save changes 
Call doc.Save( True, False )
  
'Create New Document 
(can't just open, a conflict occurs due to 
doclocking feature in LN):
Set newDoc = New NotesDocument( db )
Call doc.CopyAllItems( newDoc, True )
Call uidoc.Close( True )
Call newDoc.RemoveItem( "SaveOptions" )
Call newDoc.Save( True, False )
Set newUIDoc = 
workspace.EditDocument( True, newDoc ) 
Delete doc Set oldDoc = 
db.GetDocumentByUNID( docID$ ) 
Call oldDoc.Remove(True)


Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Ed Miller. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

This was first published in November 2005

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.