I am looking for a way in lotus script to create text in a memo body, based on variable’s data which needs to be built in a “Do While” loop.With a connection to a DB2 database, I am comparing the key value of records in a Notes DB.
If I find the record does not exist in the Notes DB then I want to write the key value with some text to a variable that I can use in the body of a memo.
Dim doc As NotesDocument
Dim rtitem As Variant
'…set value of doc…
Set rtitem = doc.GetFirstItem( “Body” )
If ( rtitem.Type = RICHTEXT ) Then
Call rtitem.AppendText( “Add text to the rich text item” )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText(“Add more text to rich text item”)
Call doc.Save( False, True )
End If
So you would just modify this to include your value in the string you are appending
Example
Call rtitem.AppendText( “Employee Number " & EmpNum & " not found in Notes database” )
Because it is a new document, there isnt a Body field to begin with. Use the CreateRichTextItem method of the NotesDocument class to create one then you can append text to it.
If this is a new document and not an existing document then you need something like as it doesn’t already exist. Be sure to look in help for other examples too.
Dim memoDoc As NotesDocument
Dim employeesNotfound As NotesRichTextItem
Dim memoDoc As New NotesDocument (gLibCurrentDatabase)
Set employeesNotfound = New NotesRichTextItem( memoDoc,“Body” )
OK Carl we are almost there, however the string value that I need to append contains a numeric value that I covert to string.
key = LCEMPNO.Value(0)
Call rtEmployeesNotfound.AppendToTextList(“Employee Number: " + CStr ( key ) + " not found in Notes database”)…
So the AppendToTextList method does not like the CStr function. I get an error 4199: “Item %1 is not of type Text, special type not set” . Any idea why this would not work?
Yes - you’re using AppendToTextList against a NotesRichtextItem, and that’s not allowed. (NotesRichTextItem inherits from NotesItem, so it does have the method, but it always throws an error once the underlying item is used as Rich Text.) You should be using AddNewline() and AppendText().