When is Rich Text NOT Rich Text?

I have a form that is used to create a document, using LotusScript, in one database and then mailed to another.

There is a field on the form that is written to via an agent (we’ll call it field1) - it takes the contents of an editable (rich text) field (let’s call this field2) on the form and adds the contents to field1. Field1 is currently a text field that I want to change to a rich text field because I need to preserve the formatting entered by the user in field2.

I changed field1 to rich text on both forms - the one used in the original database where the document is created and the one used to display the document in the second database.

I had it create a new document using this form. However, the field, which is null when initially created, shows the data type as text. Therefore, when the agent is used to update the field, as a rich text field, the agent errs out because it doesn’t see it as a rich text field.

I just need to be pointed in the right direction. Does anyone have any idea why this might be happening? Is there something I’m overlooking?

Subject: When is Rich Text NOT Rich Text?

In yr code how do you declare the rtf variable?

dim newfield as notesrichtextitem

set newfield = newdoc.createrichtextitem(“field2”)

or

simply use the notesitem copytodocument method without declaring the new field.

olditem.copytodocument(newdoc)

check the help for notesitem and notesdocument properties and methods.

Subject: RE: When is Rich Text NOT Rich Text?

I don’t declare it in the code when it is created. It is a field on the form that is set to Rich Text.

Later, when I go to write to the field (after the document was already saved, etc.) I try to dim a rich text item and then do a getfirst item, but it errs out.

Subject: RE: When is Rich Text NOT Rich Text?

if it is an existing document, then you need to open and save the document for the existing field to be set as RTF

Subject: RE: When is Rich Text NOT Rich Text?

My problem was that I could not open and save the document. Users opened the document over the web and an agent would run when they saved it that would do the processing. That process did not set the field as rich text.

However, we have finally worked up a solution. When the document is originally created, even though the field is set up as a rich text field on the form, we go ahead and create the field as a rich text field while crerating the document in script. Now when it is saved and mailed to the other database it is recognized as it should be!

Thanks for your suggestions. Good to know there are others out here willing to help when we’ve hit a dead end.

Subject: When is Rich Text NOT Rich Text?

I think this is what you are after. To keep the content of field1 while appending field2 to it and making sure the result is rich text:

Dim field1 as notesrichtextitem

Dim field2 as notesrichtextitem

dim tmp_field1text as string

’ ********************************************************************

’ If field1 is rich text, just get a handle to this item.

’ If it is not rich text, grab its text, remove the item and

’ create another, rich text item of the same name.

’ ********************************************************************

set field1 = doc.getfirstitem(“field1”)

select case field1.Type

case RICHTEXT

’ do nothing

case else

tmp_field1text = field1.text

call field1.remove

set field1 =new notesrichtextitem(doc, “field1”)

call field1.appendtext(tmp_field1text)

end select

’ ********************************************************************

’ Append field2 to field1.

’ ********************************************************************

set field2 = doc.getfirstitem(“field2”)

call field1.appendrtitem(field2)

Subject: RE: When is Rich Text NOT Rich Text?

That sounds like a solution to help with existing documents that I need to convert. All future documents will come through correctly though.

Thank you very much for the input. I really appreciate it. I wish I would have checked for your repsonse sooner, but I thought it was supposed to send me an email when there was something posted…I didn’t receive an email at all. Strange, huh?

Thanks again.