例: Formula property (NotesViewColumn - LotusScript®)

  1. 次のエージェントは、ビューの列がフィールドまたは式に基づいているかどうかを表示し、フィールドのアイテム名と式の式を表示します。
    Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim view As NotesView
      Dim f As String
      Set db = session.CurrentDatabase
      Set view = db.GetView("View A")
      Forall vc In view.Columns
        title = vc.Title
        If title = "" Then title = "<No title>"
        If vc.IsField Then
          Messagebox "Column is based on field " & _
          vc.ItemName,, _
          "Column " & vc.Position & " - " & title
        Elseif vc.IsFormula Then
          Messagebox "Column is based on formula:" & Chr(13) & _
          vc.Formula,, _
          "Column " & vc.Position & " - " & title
        Else
          Messagebox "IsField and IsFormula are both False",, _
          "Error"
        End If
      End Forall
    End Sub
  2. 次のエージェントは、列の式を切り替えます。
    Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim view As NotesView
      Dim vc As NotesViewColumn
      Dim f As String
      Set db = session.CurrentDatabase
      Set view = db.GetView("View A")
      Set vc = view.Columns(2)
      If Not vc.IsFormula Then Exit Sub
      If vc.Formula = "@Created" Then
        vc.Formula = "@Modified"
        vc.Title = "Modified"
      Else
        vc.Formula = "@Created"
        vc.Title = "Created"
      End If
    End Sub