Rich Text Field extraction problem - LS

I am having a problem extracting a rich text item from a document in database A and placing it in a different document in database B. Here is the code that I am using:

Dim rtItem As NotesRichTextITem

Set rtItem = IRESdoc.GetFirstItem(“Resume_1”)

Call rtItem.CopyItemToDocument(GBSdoc,“ImportResume”)

“Resume_1” is on the document in database A

“ImportResume” is a RT field on document in database B

The extract is successful, except the receiving field for the rtItem is “$File” (Data Type: Attached Object) and not “ImportResume”.

Hope this is understandable. Thanks in advance for any ideas.

Subject: Rich Text Field extraction problem - LS

that may be completely out of the problem but do you save your GBSDoc?

Subject: RE: Rich Text Field extraction problem - LS

Yes, I do the saves:On the backend doc:

Call GBSdoc.Save(True, True)

Then follow that up with the UIDoc saves:

uidocGBSdoc.Refresh

uidocGBSdoc.Save

But, still the RTItem goes to the $File. It is very puzzling to me. Any suggestions?

Subject: RE: Rich Text Field extraction problem - LS

That really sounds pretty puzzling. Are you sure that the rich text is saved as rich text and not MIME? I’m not sure that would have the effect you are seeing, but it might explain something.

Subject: RE: Rich Text Field extraction problem - LS

NOt sure what you mean by saving as MIME rather that Rich TExt ; the field is defined as a rich text field so I don’t know how it would save as anything else but.

Subject: RE: Rich Text Field extraction problem - LS

Many things are more complex than they seem. In this case, look at the second tab of the field properties. If the Store contents as HTML and MIME is checked, then when the document is saved, the rich text will be converted to HTML and MIME, and when it is opened again, it will be converted back to rich text for display.

The easiest way to tell is to look at an existing document’s properties from the view, not from the open document, and see if the Body field, or whatever your rich text field is, is in Rich Text or in MIME. If it is in MIME, the Body fields will each say MIME Part, as below:

Subject: RE: Rich Text Field extraction problem - LS

Hi Ben, thanks for all the information that you are providing.

  1. Store Contents as HTML and MIME is NOT checked.

  2. Field Name: ImportResume

Data Type: Rich Text

Data Length: 122 bytes

Seq Num: 4

Dup Item ID: 0

Field Flags:

Also, for your information, I am running this code from a button on the form. I ran similar code from an action button on a view for this same form, but ran it as an agent call. The same code for the RT field worked fine and the attachment was extracted to the proper field. Here is the current code that I am using:

From the action button on the form:

@Command( [ToolsRunMacro] ; “(College - Extract Resume from IRES 2)” )

Sub Initialize

' this button will extract the Rich Text resume from the "Resume" document in the IRES Db 

Dim boxType As Long, answer As Integer

userMessage = "This process will extract the Candidate resume from the IRES database. Do you want to continue?"

boxType& = 4 + 32

answer% = Messagebox  (userMessage , boxType, "Message to User")

If answer% =  7 Then End



Dim workspace As New NotesUIWorkspace

Dim session As New NotesSession

Dim GBSdb As NotesDatabase

Set GBSdb = session.CurrentDatabase



Dim GBSdoc As NotesUIDocument

Set GBSdoc = workspace.CurrentDocument

Dim	GBSdocBack As NotesDocument



'IRES Database

Dim IRESdb As NotesDatabase

Dim IRESdoc As NotesDocument

Dim view As NotesView

Set IRESdb = New NotesDatabase("D01DBL92/01/A/IBM","h_dir\hr_staff\ires.nsf")

Set view = IRESdb.GetView ("GBSExtract_1" )



Dim rtItem As NotesRichTextITem



candidateName = Trim(GBSdoc.fieldGetText("firstName")) + Trim(GBSdoc.fieldGetText("MiddleInitial")) + Trim(GBSdoc.fieldGetText("lastName"))



Set IRESdoc = view.GetDocumentByKey( candidateName )

If IRESdoc Is Nothing Then

	Messagebox "Cannot find IRES resume document for " + candidateName

	End

End If



Set GBSdocBack = GBSdoc.document

Set rtItem = IRESdoc.GetFirstItem("Resume_1")

Call rtItem.CopyItemToDocument(GBSdocBack,"ImportResume")

Call GBSdocBack.Save(True, True)



Call GBSdoc.Refresh

Call GBSdoc.Save



Messagebox "The Candidate Resume extract from the IRES database has completed."

End Sub