2

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.

Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
CinNL1
  • 23
  • 1
  • 3

3 Answers3

3

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
nempoBu4
  • 6,521
  • 8
  • 35
  • 40
  • Thanks, this did more or less the trick. Just one question though, it loops through fine but I get duplicate columns created. It seems that when it reaches the bottom, it continues from the top again but not the entire form. Any idea why that is? – CinNL1 Feb 10 '16 at 14:06
  • A problem with this approach is that Views present the content of Items in Documents which may not be the same as the Fields on the Form used to create and/or display the documents. Computed for Display fields will not be on the documents and items not on the form might be added by code in the Form or Agents. – Newbs Feb 10 '16 at 16:00
  • @CinNL1 There is something wrong with your code. You can try to use `Arrayunique` to remove duplicates: `fields = Arrayunique(form.Fields) : Forall field In fields : Call view.CreateColumn(, field, field) : End Forall`. – nempoBu4 Feb 11 '16 at 03:54
  • @Newbs The question is about the easy way. Sure, there are can be more complex way which takes into account the `Computed for Display` fields or even `Computed Subform` fields. – nempoBu4 Feb 11 '16 at 04:10
1

You could open a document created with the form and iterate thorugh the NotesItems. There you can get the field names.

The code could looks something like this:

Dim field List As String

Forall i in doc.Items
    field(i.Name) = i.Text
End Forall

You now have a list containing the text representation of the field as value and the name of the field as the list tag.

Or you could do this on each document and export all the values like that. Creating a view with 100 columns would create a huge view index. Not a great idea.

Karl-Henry Martinsson
  • 2,770
  • 15
  • 25
0

Maybe could you use

ReadViewEntries Use this command to access view data in XML form without appearance attributes such as fonts, list separators, date formats, HTML settings, view templates and frame redirections. Syntax:

http://Host/Database/ViewName?ReadViewEntries

Link: http://www.ibm.com/developerworks/lotus/library/ls-Domino_URL_cheat_sheet/

Emmanuel Gleizer
  • 1,990
  • 16
  • 26