About This Code
Brief Description:
Lotusscript Class To Convieniently Access Design Elements
Contributor:
Andrew Jones
Last Modified:
05 Dec 2003
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
Usage / Example
Inside of a Domino Database exists data documents and design documents. The design documents are the forms, views, agents, etc that make up a databases design. The standard Notes classes allow easy access to the data documents, but do not provide any easy methods for accessing the design.
The purpose of the DatabaseDesign class is to allow you easy access to the design documents in a DominoDatabase in LotusScript. It returns the design documents, at which point they can be examined, modified, copied to other databases or deleted. The documents are returned as standard NotesDocument objects, so once retrieved you can perform any operation on them that is allowed in a regular NotesDocument.
---How To Use ---
To use the DatabaseDesign class, you must first copy and paste the DBDesign script library into the database where you wish to use it.
Then in the script which you need to use the library, add this line to the Options section.
Use "DBDesign"
Then to instantiate a new DatabaseDesign object, call the createDatabaseDesign function.
Dim session as New NotesSession
Dim db as NotesDatabase
Dim dbDesign as DatabaseDesign
Set db = session.currentDatabase
Set dbDesign = createDatabaseDesign( db)
'To get all the forms in a database, simply get the formDocuments property.
Dim forms as variant
forms = dbDesign.formDocuments
'Check to make sure there are forms before processing
If Not IsEmpty( forms) Then
Forall formdoc In forms
'This prints out all the form names
print formdoc.getItemValue( "$Title")(0)
end Forall
End If
' To get a specific form in a database, pass in the form name to the getFormByName method.
Dim form as NotesDocument
set form = dbDesign.getFormByName( "MyForm")
If Not form Is Nothing Then
'do something with form here
End If
'To copy a design element to another database, use the NotesDocument.copyToDatabase method
dim otherdb as new NotesDatabase( "server", "file.nsf")
set form = dbDesign.getFormByName( "FormToCopy")
If Not form Is Nothing Then
dim formcopy as NotesDocument
set formcopy = form.copytodatabase(otherdb)
call formcopy.save(true, true)
End If
---Properties---
Property agentDocuments as Variant
Returns all agents as an array of NotesDocuments. If none could be retrieved, it returns a empty variant.
Property cacheDocuments as Integer
This is a readable and writable property. When true, it caches the retrieval of design notes in memory to speed up subsequent retrievals. It is true by default.
Property databaseScriptDocuments as Variant
Returns all database scripts as an array of NotesDocuments, typically there will be only one per database. If none could be retrieved, it returns a empty variant. Read only.
Property folderDocuments as Variant
Returns all folders as an array of NotesDocuments. If none could be retrieved, it returns a empty variant. Read only.
Property formDocuments as Variant
Returns all forms as an array of NotesDocuments. If none could be retrieved, it returns a empty variant. Read only.
Property framesetDocuments as Variant
Returns all framesets as an array of NotesDocuments. If none could be retrieved, it returns a empty variant. Read only.
Property helpAboutDocuments as Variant
Returns all help about documents as an array of NotesDocuments, typically there will be only one per database.. If none could be retrieved, it returns a empty variant. Read only.
Property helpUsingDocuments as Variant
Returns all help using documents as an array of NotesDocuments, typically there will be only one per database. If none could be retrieved, it returns a empty variant. Read only.
Property iconDocuments as Variant
Returns all database icons as an array of NotesDocuments, typically there will be only one per database.. If none could be retrieved, it returns a empty variant. Read only.
Property imageDocuments as Va
Code
%REM
********************************************************************************
This library was originally created by Damien Katz of Iris Associates, Aug. 1999
This library may be freely distributed, modified and used only if this header
is kept intact,
unchanged and is distributed with the contents of the library.
Please share any fixes or enhancements and send them to Damien_katz@iris.com so
I can add
it the library.
If you find this library useful, send me a mail message and let me know what
you're using it for.
Thanks.
********************************************************************************
NOTE:
To instantiate a new DatabaseDesign object, do not attempt to instantiate it
directly,
instead call the createDatabaseDesign method, it will return a new instantiated
object.
%END REM
'Set this flag to true to always use the platform independent method
Const FLAG_NEVER_USE_NATIVE_API_CALLS =False
Const DESIGN_NOTE_NAME_ITEM = "$TITLE"
Const NOTE_CLASS_DOCUMENT = &H0001 ' document note
Const NOTE_CLASS_DATA = NOTE_CLASS_DOCUMENT ' old name for document note
Const NOTE_CLASS_INFO = &H0002 ' notefile info (help-about) note
Const NOTE_CLASS_FORM = &H0004 ' form note
Const NOTE_CLASS_VIEW = &H0008 ' view note
Const NOTE_CLASS_ICON = &H0010 ' icon note
Const NOTE_CLASS_DESIGN = &H0020 ' design note collection
Const NOTE_CLASS_ACL = &H0040 ' acl note
Const NOTE_CLASS_HELP_INDEX = &H0080 ' Notes product help index note
Const NOTE_CLASS_HELP = &H0100 ' designer's help note
Const NOTE_CLASS_FILTER = &H0200 ' filter note
Const NOTE_CLASS_FIELD = &H0400 ' field note
Const NOTE_CLASS_REPLFORMULA = &H0800 ' replication formula
Const NOTE_CLASS_PRIVATE = &H1000
Const NOTE_CLASS_ALLNONDATA = &H7FFE
Const DESIGN_FLAG_ADD = "A"
Const DESIGN_FLAG_ANTIFOLDER = "a" ' VIEW: Indicates that a view is an
antifolder view
Const DESIGN_FLAG_BACKGROUND_FILTER = "B" ' FILTER: Indicates
FILTER_TYPE_BACKGROUND is asserted
Const DESIGN_FLAG_INITBYDESIGNONLY="b" ' VIEW: Indicates view can be initially
built only by designer and above
Const DESIGN_FLAG_NO_COMPOSE = "C" ' FORM: Indicates a form that is used only
for
' query by form (not on compose menu).
Const DESIGN_FLAG_CALENDAR_VIEW = "c" ' VIEW: Indicates a form is a calendar
style view.
Const DESIGN_FLAG_NO_QUERY = "D" ' FORM: Indicates a form that should not be
used in query by form
Const DESIGN_FLAG_DEFAULT_DESIGN = "d" ' ALL: Indicates the default design
note for it"s class (used for VIEW)
Const DESIGN_FLAG_MAIL_FILTER = "E" ' FILTER: Indicates FILTER_TYPE_MAIL is
asserted
Const DESIGN_FLAG_PUBLICANTIFOLDER = "e" ' VIEW: Indicates that a view is a
public antifolder view
Const DESIGN_FLAG_FOLDER_VIEW = "F" ' VIEW: This is a V4 folder view.
Const DESIGN_FLAG_V4AGENT = "f" ' FILTER: This is a V4 agent
Const DESIGN_FLAG_VIEWMAP = "G" ' VIEW: This is ViewMap/GraphicView/Navigator
Const DESIGN_FLAG_OTHER_DLG = "H" ' ALL: Indicates a form that is placed in
Other... dialog
Const DESIGN_FLAG_V4PASTE_AGENT = "I" ' FILTER: This is a V4 paste agent
Const DESIGN_FLAG_IMAGE_RESOURCE = "i" ' FORM: Note is a shared image resource
Const DESIGN_FLAG_JAVA_AGENT = "J" ' FILTER: If its Java
Const DESIGN_FLAG_JAVA_AGENT_WITH_SOURCE = "j" ' FILTER: If it is a java agent
with java source code.
Const DESIGN_FLAG_LOTUSSCRIPT_AGENT = "L" ' FILTER: If its LOTUSSCRIPT
Const DESIGN_FLAG_DELETED_DOCS = "l" ' VIEW: Indicates that a view is a
deleted documents view
Const DESIGN_FLAG_QUERY_MACRO_FILTER = "M" ' FILTER: Stored FT query AND macro
Const DESIGN_FLAG_SITEMAP = "m" ' FILTER: This is a site(m)ap.
Const DESIGN_FLAG_NEW = "N" ' FORM: Indicates that a subform is listed when
making a new form.
Const DESIGN_FLAG_HIDE_FROM_NOTES = "n" ' ALL: notes stamped with this flag
'will be hidden from Notes clients
'We need a separate value here
'because it Is possible To be
'hidden from V4 AND to be hidden
'from Notes, and clearing one
'should not clear the other
Const DESIGN_FLAG_QUERY_V4_OBJECT = "O" ' FILTER: Indicates V4 search bar query
object - used in addition to "Q"
Const DESIGN_FLAG_PRIVATE_STOREDESK = "o" ' VIEW: If Private_1stUse, store the
private view in desktop
Const DESIGN_FLAG_PRESERVE = "P" ' ALL: related to data dictionary
Const DESIGN_FLAG_PRIVATE_1STUSE = "p" ' VIEW: This is a private copy of a
private on first use view.
Const DESIGN_FLAG_QUERY_FILTER = "Q" ' FILTER: Indicates full text query ONLY,
no filter macro
Const DESIGN_FL
Comments
Posted by Eduardo R Redolfi on 12/17/2002 09:07:57 AMtruncated code
Posted by Michael J Conway on 05/20/2004 04:18:31 AMCode incomplete?
Hi.
The included code segment appears incomplete. Sounds like in interesting piece of work I'd really like to take a look at. Any chance of posting the code in it's complete form? If possible that would be great!
Many thanks.
Mike Conway.
Posted by Markus Bawidamann on 09/15/2004 06:43:36 AMsame here
Sound like a nice piece of code.
Is there a way to get the full code of this? Where?
many thanks
Markus
Posted by Elvin Risti on 09/21/2004 05:44:58 AMtry this ...
link: http://www.openntf.org/Projects/codebin/codebin.nsf/CodeByDate/0A43C22F85C611D686256EC1002566B5