Adding text to RT item appears to work but saves as blank?

Hi… I am trying to add some text and a doclink to a rich text field (depmi) on a document (currdoc). The following code seems to work… as I step through it, I watch value of the depmi field in the debugger, and it appears to get the values that I want. However, when I go to save the document, the value is gone and the field is empty. What am I doing wrong??

Dim ws As New NotesUIWorkspace

Dim dc As NotesDocumentCollection

Dim uidoc As NotesUIDocument

Dim currdoc As NotesDocument

Dim doc As NotesDocument

Dim rtitem As Variant



Set uidoc = ws.CurrentDocument

Set currdoc = uidoc.Document

Set dc = ws.PickListCollection(PICKLIST_CUSTOM, True, "", "v_dir\votes.nsf", "(Depend)", "Select Milestone Dependencies", "Select", "Milestone")





Set doc = dc.GetFirstDocument



While Not (doc Is Nothing)

	Set rtitem = currdoc.GetFirstItem("depmi")

	Call rtitem.AppendText(doc.title(0))

	Call rtitem.AppendDocLink(doc, "Link")

	Call rtitem.AddNewline(1)

	Call currdoc.Save(True, False)

	Set doc = dc.GetNextDocument(doc)

Wend

Subject: RE: Adding text to RT item appears to work but saves as blank?

It sounds like you’re expecting the value you create in the back-end rich text will be visible on screen. This doesn’t happen automatically. See this: Update rich text tip.

Subject: RE: Adding text to RT item appears to work but saves as blank?

Andre, I make the updates, and I can see through the debugger that the field gets the values. Then I call a backend save. Then I try saving and closing the document in the UI. But when I reopen the document, the field is still blank.

Thanks

Subject: RE: Adding text to RT item appears to work but saves as blank?

If you save the document in the UI, you are saving the document with the blank rich-text value which is shown in the UI at that time. This overwrites the changes you saved from the back-end.

Please try it the way I suggested.

Subject: Adding text to RT item appears to work but saves as blank?

Have you tried declaring rtitem as a notesrichtextitem?

Subject: RE: Adding text to RT item appears to work but saves as blank?

Yes, I tried that as well, but no dice. I also tried set rtitem = new notesrichtextitem (currdoc, “depmi”) and that didn’t work either.

Thanks…

Ben

Subject: RE: Adding text to RT item appears to work but saves as blank?

try it like this instead:

Dim ws As New NotesUIWorkspace

Dim dc As NotesDocumentCollection

Dim uidoc As NotesUIDocument

Dim currdoc As NotesDocument

Dim doc As NotesDocument

Dim rtitem As Variant

Set uidoc = ws.CurrentDocument

Set currdoc = uidoc.Document

Set dc = ws.PickListCollection(PICKLIST_CUSTOM, True, “”, “v_dir\votes.nsf”, “(Depend)”, “Select Milestone Dependencies”, “Select”, “Milestone”)

Set rtitem = currdoc.GetFirstItem(“depmi”) ’ moved up

Set doc = dc.GetFirstDocument

While Not (doc Is Nothing)

Call rtitem.AppendText(doc.title(0))

Call rtitem.AppendDocLink(doc, “Link”)

Call rtitem.AddNewline(1)

Set doc = dc.GetNextDocument(doc)

Wend

Call currdoc.Save(True, False) ’ moved down