例: Reload method

  1. 次のボタンは Qty_1 から 30 までのアイテムをゼロに設定し、フロントエンド文書を対応するバックエンド文書から再読み込みします。
    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)
      Next
      Call uidoc.Reload
      uidoc.AutoReload = True ' restore default
    End Sub
  2. 次のコードは、フロントエンドの文書を閉じて開きます。これにより Queryclose、Queryopen、Postopen などのフォームイベントが起動するため注意が必要です。また、uidoc.Refresh は計算結果フィールドと入力確認式も起動します。このため、@IsDocBeingSaved または @IsDocBeingSent が true でないかぎり確認式が @Failure を返さないように作成してください。
    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
    Else
      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
    uidocNew.Document.RemoveItem("SaveOptions")
    If strFieldname <> "" Then uidocNew.GotoField(strFieldname)
    ' return focus to field that was current before