Manage Learn to apply best practices and optimize your operations.

Update Rt field on the screen without saving the document

This tip describes how to update Rt field on the screen without saving the document.

When using LS for updating a rich text item in the current document, the changes are not immediately visible on the screen. A solution can be to save the document en reopen it, but in that case all the changes are saved without the wish of the user.

I have made a workaround for this problem.
Create two agents and call these agents from a button like this:
Do(
@Command([ToolsRunMacro];"Agent1");
@Command([ToolsRunMacro];"Agent2"))


Agent1:
Sub Initialize
 Dim db As notesdatabase
 Dim session As New NotesSession
 Dim workspace As New NotesUIWorkspace
 Dim uidoc As notesuidocument
 Dim thisdoc As NotesDocument. linkdoc 
as notesdocument
 Dim rtitem As Variant
  
 Set db = session.CurrentDatabase
 Set uidoc=workspace.currentdocument
 uidoc.refresh True  'to update RT fields
 If Not uidoc.editmode Then Exit Sub
 Set thisdoc=uidoc.document
 
 On Error Goto ErrorHandler
 '….Place here your own 
code to create a linkdoc

 Set rtitem = thisdoc.getfirstitem
("Remarks")
 Call rtitem.addnewline(1)
           '….create your doc link
 Call rtitem.AppendDocLink( linkdoc, 
linkdb.Title )
 Call rtitem.AddTab( 1 )
 Call rtitem.AppendText( linkdoc.title(0))
 
 succes=thisdoc.computewithform
 (False, False)
 thisdoc.SaveOptions="0"
 Call uidoc.close
 
 Set uidoc = workspace.EditDocument
( True, thisdoc)
 Call uidoc.gotofield("Remarks")
 uidoc.refresh True
 Exit Sub
 
ErrorHandler:
 Print "Error #" & Trim$(Str$(Err)) & ": "
 & Error$
 Resume Next
End Sub

Agent 2:
Sub Initialize
 Dim session As New NotesSession
 Dim workspace As New 
NotesUIWorkspace
 Dim uidoc As notesuidocument
 Dim thisdoc As NotesDocument
 
 Set uidoc=workspace.currentdocument
 Set thisdoc=uidoc.document
 thisdoc.SaveOptions="1" 
 
End Sub

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close