From a button click event I wish to add a 'time stamp' with user name into the body of a rich text item, ie log the time and the user for new updates in the field. For some reason the style is not applied.
I have a further problem due to the requirement to close and open the document on RT items in that the cursor returns to the top of the field rather than the bottom I don't believe there is solution for that though?
Any help is appreciated
Function TimeStampBold(fieldname As String)
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim uidocNew As NotesUIDocument
Dim rti As NotesRichTextItem
Dim rtiStyle As NotesRichTextStyle
set uidoc = workspace.currentdocument
uidoc.Refresh True
Set doc = uidoc.Document
Set rti = doc.Getfirstitem(fieldname)
Set rtiStyle = session.CreateRichTextstyle()
rtiStyle.Bold = True
rtiStyle.Fontsize=8
Print rtiStyle.Bold ' Returns True
Call rti.AppendStyle(rtiStyle) Style is not applied.
If (Len(uidoc.FieldGetText("Body"))) = 0 Then
Call rti.AppendText (Format$ (Now(), "d-mmm-yy h:mm"))
Else
Call rti.Addnewline(2)
Call rti.AppendText (Format$ (Now(), "d-mmm-yy h:mm"))
End If
Call rti.AppendText (" " & session.CommonUserName &" - ")
rtiStyle.Bold=False
Call rti.Appendstyle(rtistyle)
rti.Update
doc.SaveOptions ="0"
Call uidoc.Close(True)
Set uidocNew = workspace.EditDocument(True, doc,,,,True)
uidocNew.Document.Removeitem("SaveOptions")
uidocNew.GotoField(fieldname)
End Function
I don't know if this will work, but perhaps you can set a hidden field in the document to '1' and put some code in the PostOpen event script to check that field, and do the gotoField call if it the value is '1'. (And reset the field value back to '0' in the PostOpen, too.)