Examples: Reload method

  1. This button sets items Qty_1 thru 30 to zero, then reloads the front-end document from the corresponding back-end document.
    Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim i%
      Set uidoc = workspace.CurrentDocument
      uidoc.AutoReload = False	' for best performance
      Set doc = uidoc.Document
      For i = 1 To 30
        Call doc.ReplaceItemValue("Qty_" & i, 0)
      Call uidoc.Reload
      uidoc.AutoReload = True ' restore default
    End Sub
  2. This code closes and opens a document in the front-end. Be aware that this activates the form events such as Queryclose, Queryopen, and Postopen. Also, uidoc.Refresh activates computed field and input validation formulas, so you should write the validation formulas to not return @Failure unless @IsDocBeingSaved or @IsDocBeingSent is true.
    Dim wksp As New NotesUIWorkspace
    Dim session As New NotesSession
    Dim uidoc As NotesUIDocument, uidocNew As NotesUIDocument
    Dim doc As NotesDocument
    Dim rti As NotesRichTextItem
    Dim strFieldname As String
    Set uidoc = wksp.CurrentDocument
    uidoc.Refresh True ' if user may have modified the rich text field
    Set doc = uidoc.Document ' get the back-end document
    strFieldname = uidoc.CurrentField ' remember the current field if any
    Set rti = doc.GetFirstItem("fieldname") ' put fieldname here e.g. "Body"
    ' Make your rich text changes here, for instance:
    Call rti.AddNewLine(1, True)
    Call rti.AppendText(Now & ": log entry.")
    If session.NotesBuildVersion >= 190 Then
      rti.Update ' ND6 only
      Call doc.ComputeWithForm(True, False)
     ' caution may erase field values if @Db functions in formulas
    End If
    doc.SaveOptions = "0"
    ' to close document without "do you want to save" prompt
    ' for mail-in doc, may need to set MailOptions="0
    Call uidoc.Close(True)
    Set uidocNew = wksp.EditDocument(True, doc, , , , True)
    Delete uidoc
    If strFieldname <> "" Then uidocNew.GotoField(strFieldname)
    ' return focus to field that was current before