Home > Domino Tips > Developer > LotusScript > Capture rich-text comments in Lotus Notes fields using LotusScript
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Capture rich-text comments in Lotus Notes fields using LotusScript


Ron Sorrell
04.01.2008
Rating: -2.62- (out of 5)


Lotus Notes, Domino, Workplace and WebSphere tips and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


There are many ways to capture comments in normal Lotus Notes text fields, but I needed to capture rich-text comments such as colors, different fonts, etc.

I didn't have to trim any comments, but I included the LotusScript code for that as a reference. I've found that you can capture rich-text comments using the NotesRichTextStyle class, which is available in Lotus Notes Domino 4.6 and higher.

Following is the LotusScript code I used on the QueryClose event.

Sub Queryclose(Source As 
Notesuidocument, Continue As Variant)
On Error Goto Oops
Dim db As NotesDatabase
Dim session As New NotesSession
Dim doc As NotesDocument
Set doc = session.CurrentDatabase.
GetDocumentByUNID(Source.Document.
UniversalID)

'Declare the rich text items 
Dim vNarrativeTemp As NotesRichTextItem
Dim vNarrative As NotesRichTextItem
Dim itemN As Variant


'set the rich text items 
itemN = doc.GetItemValue("NarrativeTemp")
Set vNarrativeTemp = doc.GetFirstItem
("NarrativeTemp")
Set vNarrative = doc.GetFirstItem("Narrative")

Dim richStyle As NotesRichTextStyle
Set richStyle = session.CreateRichTextStyle

'Narrative Field
If (itemN(0) <> "")Then  
richStyle.Bold = True
Call vNarrative.AppendStyle(richStyle)
Call vNarrative.AppendText(Format$(Now, 
"mm/dd/yy hh:nn AM/PM") & " by " & 
session.CommonUserName & ": ")  
	 
Related resources from SearchDomino.com:
Tip: How to create a comments field for Lotus Notes documents

Tip: Setting row colors by category in a Lotus Notes view

Tutorial: 30 LotusScript tips

LotusScript Reference Center

richStyle.Bold = False Call vNarrative.AddNewLine(1) Call vNarrative.AppendRTItem (vNarrativeTemp) Call vNarrative.AddNewLine(1) Call vNarrativeTemp.Remove End If 'Save the doc Call doc.Save(True, False) TheEnd: Continue = True Exit Sub Oops: Resume TheEnd End Sub Sub TrimNotes(fixthis) t= fixthis trimmed = "" found = "N" 'look for chr(13) or chr(10) and if found 'look for another and if found remove the second one For x = 1 To Len(t) 'found the 1st CR or LF - accept it If (Mid ( t , x , 1 ) = Chr(13) Or Mid ( t , x , 1 ) = Chr(10)) And found = "N" Then found = "Y" trimmed = trimmed & Chr(10) Goto getnext End If 'found a 2nd or subsequent CR or LF - throw it away If (Mid ( t , x , 1 ) = Chr(13) Or Mid ( t , x , 1 ) = Chr(10)) And found = "Y" Then Goto getnext End If trimmed = trimmed & Mid ( t , x , 1 ) found = "N" getnext: Next t = trimmed 'change double spaces to single space a = " " b = " " If (a<>b) Then i=Instr(t,a) done=(i=0) While Not done t=Left(t,i-1)+b+Mid(t,i+Len(a)) n=i+1 i=Instr(n,t,a) If i=0 Then i=Instr(t,a) done=(i=0) Wend End If 'change // to / a = "//" b = "/" If (a<>b) Then i=Instr(t,a) done=(i=0) While Not done t=Left(t,i-1)+b+Mid(t,i+Len(a)) n=i+1 i=Instr(n,t,a) If i=0 Then i=Instr(t,a) done=(i=0) Wend End If 'change double hyphens -- to single - a = "--" b = "-" If (a<>b) Then i=Instr(t,a) done=(i=0) While Not done t=Left(t,i-1)+b+Mid(t,i+Len(a)) n=i+1 i=Instr(n,t,a) If i=0 Then i=Instr(t,a) done=(i=0) Wend End If fixthis = Trim(t)

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Ron Sorrell. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
LotusScript
Reading a binary field in an Oracle database with LotusScript
LotusScript equivalent of @Picklist for Lotus Notes
Launch large attachments within an email from a Notes database
How to find files on a hard drive or mapped network with LotusScript
Update the ACL from the Roles view with LotusScript
LotusScript agent moves tagged spam email to junk mail folder
Create a personalized greeting for Lotus Notes database users
Fail-safe rich-text validation using LotusScript
How to export Lotus Notes views to a Microsoft Excel database
Create file system labels for Microsoft Excel and Word mail merges

LotusScript
Reading a binary field in an Oracle database with LotusScript
LotusScript equivalent of @Picklist for Lotus Notes
Launch large attachments within an email from a Notes database
How to find files on a hard drive or mapped network with LotusScript
Update the ACL from the Roles view with LotusScript
LotusScript agent moves tagged spam email to junk mail folder
Set a value in a field existing in another Lotus Notes database
Create an automatic scheduled view export in Excel
Top 10 LotusScript tips
Create a personalized greeting for Lotus Notes database users

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts