Search code examples
lotus-noteslotus-dominolotus

Display all Fields from a Form in a View in Lotus Script or Lotus Formula


Is there any easy way to create a view with all available fields from a form?

I have a form with over 100 fields and to create a view with all fields will take too much time. The aim is to export the data once it's in the view.


Solution

  • You can create View by using NotesDatabase.CreateView method, and create columns to this View by using NotesView.CreateColumn. The list of all fields in Form you can get from NotesForm.Fields property. The Form itself you can get from NotesDatabase.GetForm method.
    Here is example:

    Dim ses As New NotesSession
    Dim db As NotesDatabase
    Dim form As NotesForm   
    Dim view As NotesView
    
    Set db = ses.CurrentDatabase
    
    formName$ = "YourFormName"
    
    Set form = db.GetForm(formName$)
    
    Set view = db.CreateView(formName$ & "Fields", {Form = "} & formName$ & {"})
    
    Forall field In form.Fields
        Call view.CreateColumn(, field, field)
    End Forall