Home > Domino Tips > Developer > LotusScript > Generate an automatic view from forms
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Generate an automatic view from forms


Guillermo Villanueva
06.06.2005
Rating: -4.58- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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.

Code

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.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
LotusScript
Display Lotus Notes user group membership details in a tree view
Alternate version of @Command forwards subform via LotusScript
Process large arrays in Notes forms without undue coding or testing
How to use LotusScript to modify a Lotus Notes view selection
Display a custom message box using a LotusScript-generated button
Debug Lotus Notes documents using extracted data
Extracting attachments from a Lotus Notes rich-text field
Programmatically replace the design of Lotus Notes databases
Reading a binary field in an Oracle database with LotusScript
LotusScript equivalent of @Picklist for Lotus Notes

LotusScript
Display Lotus Notes user group membership details in a tree view
Alternate version of @Command forwards subform via LotusScript
Process large arrays in Notes forms without undue coding or testing
How to use LotusScript to modify a Lotus Notes view selection
Display a custom message box using a LotusScript-generated button
Can I use LotusScript to merge cells in a Microsoft Word table?
Debug Lotus Notes documents using extracted data
Extracting attachments from a Lotus Notes rich-text field
Programmatically replace the design of Lotus Notes databases
Reading a binary field in an Oracle database with LotusScript

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts