Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
Grab All Fields in Database and sort

Hint Short Cut: Add this to your code & documentation to help you find this page.
http://www.notesninjas.com/#DatabaseFields or http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/DatabaseFields


This script grabs all the fields in a database by going through the forms, uniques them and then sorts them.





 

'this code grabs all the fields in the database and sticks them in the flds field
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
fieldCount = 0
Redim Preserve f(0) As String
Forall form In db.Forms
 
 If Isempty(form.Fields) Then
   'Messagebox form.Name & " has no fields"
 Else

  Forall field In form.Fields
   f(fieldcount)= field
   fieldcount=fieldcount+1
   Redim Preserve f(fieldcount)
  End Forall

 End If  

End Forall
'Messagebox "postopen " & Ubound(f)
Dim uiw As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc = uiw.CurrentDocument

Dim doc As notesdocument
Set doc = uidoc.document

Dim fun As Variant
fun =Arrayunique(f)

'Messagebox "postopen " & Ubound(fun)



Dim temp As String
'sort the fun array
For a=1 To Ubound(fun)-1
 For b=Ubound(fun) To a Step -1
  If fun(b) < fun(b-1) Then
   temp=fun(b-1)
   fun(b-1)=fun(b)
   fun(b)=temp
  End If
 Next b
Next a

 'poulate the field in the open form if required
'Call doc.ReplaceItemValue("flds",fun)


 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
Lotus Notes and Domino 6 Programming Bible by Brian Benz, Rocky Oliver
Covers all the programming techniques, concepts, and languages used with Notes and Domino, as well as the many new features of Domino 6 Thoroughly examines the Notes and Domino role with Java, XML, Web services, and other IBM products and technologies Provides extensive code and examples, many geared to the needs of administrators High-profile authors, known to their audience through conferences and articles Companion Web site shows example applications from the book running on a live Domino server and provides code download.
See at: Amazon.co.uk | Amazon.com |