RTF Pre-Fill

Hi there,

I have a rich text field which the user will fill with formatted information (title in Blue and bold, commands are in red etc).

Is there any way of pre-filling the Rich Text Field with the sections pre-formatted? i.e. have all the headings in place and in the right format?

Thanks for any suggestions

F1H

Subject: RTF Pre-Fill

Try inserting desired text in the rich text field in the QueryOpen event of the form. You can format the inserted text using NotesRichTextStyle class in LotusScript.

Alternatively, you can create a lookup document with a rich text field with text and formatting u want. In the main form QueryOpen event, you can get this lookup document and append its rich text field to your rich text field using AppendRTItem method.

Subject: RE: RTF Pre-Fill

Thanks Puneet,

I think i will go with your last idea, i will create a formatting document, with the formatting + colours set and do a lookup and append it. this will give the users the ability to change the formatting whenever they need to!

I noticed that the appendRichText works with the backend doc rather than the uidoc, how would i go about refreshing the uidoc after i run the script to import it?

Great idea, thanks for that.

F1H

Subject: RE: RTF Pre-Fill

Pls try the following:


Set doc = source.Document

–Code to Append RTItem using backend doc–

Call source.Refresh(True)


In case Refresh does not work, try source.Reload()

Subject: RE: RTF Pre-Fill

Thanks very much.

Really Appreciate it.

F1H

Subject: RTF Pre-Fill - Problem?

Hi,

Tried to code this and its running fine now, but not refreshing the UIdocument with the appended content. It is changing the RTItem’s value (in the debugger) but its not refreshing the uidocument, i have tried both refresh and reload.

Code :

Dim s As New NotesSession

Dim ws As New NotesUIWorkspace

Dim db As NotesDatabase

Dim v As NotesView

Dim FDoc As NotesDocument

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim rtitemA As Variant

Dim rtitemB As Variant



Set db = s.CurrentDatabase

Set v = db.GetView("FormatLkp")

Set uidoc = ws.CurrentDocument

Set doc = uidoc.Document

Msgbox doc.ArtType(0)

Set FDoc = v.GetDocumentByKey(uidoc.FieldGetText("ArtType"))

Set rtitemA = doc.CreateRichTextItem("SolutionRT")

Set rtitemB = FDoc.GetFirstItem( "SolutionRT" )

Call rtitemA.AppendRTItem(rtitemB)

Call doc.Save(True,True)

Call uidoc.Reload()

Thanks for any help

F1H

Subject: RE: RTF Pre-Fill - Problem?

You are right, I tried that and it didn’t work. don’t know why the uidoc.Refresh(True) is not working as mentioned in the designer help or I am missing something.

Anyway, I tried closing the uidoc and opening it again and it worked.

You will have to save the backend doc anyway before doing this. If u are writing the code in QueryOpen / Postopen, this will again cause the event to run and your code may go in a loop. So set some flag in the backend doc before saving it and in the QueryOpen / Postopen check if the flag is set then simply exit the code and don’t append the RTItem.

Here is a sample:

If doc.Flag(0)=1 Then Exit Sub

doc.Flag=1

doc.Form = “”

Call rtitemA.AppendRTItem(rtitemB)

Call doc.Save(True , false)

Call uidoc.Close()

Set uidoc = ws.EditDocumnet(True, doc)

Subject: RE: RTF Pre-Fill - Problem?

Refresh(True) doesn’t copy back-end rich text to the front end. It’s the other way around.

The Update rich text tip discusses how to get the display to refresh.

Subject: RTF Pre-Fill

I set up a special form and view with default RTF contents in it. Then, on your real form, put in a DBLookup as the default value.

@DbLookup(“”:“Nocache”;“”;“Lookup\RTF”;“Pricing Table”;“RTF_Value”)