Generate an automatic view from forms

This script searches forms in a design database and creates one view for each form within all fields.

This script searches forms in a design database and creates one view for each form within all fields. I have coded that script because I always a need a standard view for forms. Before coming up with this script, I had to create the views one by one. Now I can do that with one click.

Sub Initialize
 Dim s As New NotesSession
 Dim w As New NotesUIWorkspace
 Dim db As NotesDatabase
 Dim frm As NotesForm
 Dim vw As NotesView
 Dim frmName As String
 Dim c As NotesViewColumn
 Redim frmNames(0) As String
 
 Set db=s.CurrentDatabase
 i=0
 frmNames(i)=""
 Forall x In db.Forms
  i=i+1
  Redim Preserve frmNames(i) As String
  frmNames(i)=x.name
 End Forall
 
 frmName=""
 frmName=w.Prompt(PROMPT_OKCANCELLIST, 
"Select a Database", 
"Select a database to open.", "",frmNames)
 Set vw=db.CreateView(frmName,
{SELECT FORM = "}+frmName+{"})
 
 '-----------------------------------------------
 ' Elimination of automatically created columns
 '-----------------------------------------------
 i=0
 Forall columna In vw.Columns
  i=i+1
 End Forall
 For j=1 To i
  vw.RemoveColumn 
 Next
 
 Set frm=db.GetForm(frmName)
 Forall f In frm.Fields
  If frm.GetFieldType(f)<>1 Then 
   Set c=vw.CreateColumn(,f,f)
   Print frm.GetFieldType(f)
   Select Case frm.GetFieldType(f)
   Case AUTHORS,NAMES,READERS,1281
    a$={@name([Abbreviate];}+c.Formula+{)}
    c.Formula=a$
   Case DATETIMES,1024
    c.TimeDateFmt=0    
    c.DateFmt=6
    
   Case NUMBERS,768
    c.NumberAttrib=2
   End Select
   '-----------------------------------
-----------------------------------
   ' Special cases of columns of type 
names non-detected by GetFieldType
   '---------------------------------
-------------------------------------
   If Left$ ( f , 2 )="us" Then
    a$={@name([Abbreviate];}+c.Formula+{)}
    c.Formula=a$
   End If
   c.FontFace="Arial"
   c.HeaderFontFace="Arial"
   c.FontPointSize=9
   c.HeaderFontPointSize=9
   c.FontStyle=0
   c.HeaderFontStyle=0
  End If
 End Forall
End Sub

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Guillermo Villanueva. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

This was last published in June 2005

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close