Manage Learn to apply best practices and optimize your operations.

Partial hide design

How to hide scripting in forms and views when altering design elements.

In some cases a developer needs to alter some design elements in the client's locations such as form fields, view columns, pages or any other elements, but he/she needs all the scripting to be hidden even in the forms and views.

In ND6 we have the new class (NotesNoteCollection) that is useful and powerful to navigate, control and modify all database designs and data documents.

I have also submitted Partial replace design, which has to do with the NotesNoteCollection class. I now submit this tip, which is (I believe) is very useful for developers using the same class convention.

This routine requires designer ACL level or higher to be executed.

Note that you must keep a copy of your design before executing this code. Also, after executing this routine, you may alter the design elements (forms, pages, views and folders) and save them without losing the scripting inside them, but it very important not to alter the scripting areas. Doing so may cause you lose any call for the used routine inside them.

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

This tip was submitted to the tip library by member Sirry Hboos. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.
Here is a sample for using this call by an agent or a button.

Sub Initialize
 Dim s As New NotesSession
 Dim db As NotesDatabase

 Dim DocTypes(0 To 1)
 Set db = s.CurrentDatabase
 If db.QueryAccess(s.UserName) < ACLLevel_Designer Then
  Msgbox "Your access level doesn't allow you to execute this action."
  Exit Sub
 End If

Call HideDesignElements(db, DocTypes)
End Sub

Public Sub HideDesignElements(db As NotesDatabase, DocTypes As Variant)
DocTypes are arrays of strings

This routine hides the script of doctypes design elements

 'here are some fields witch carrying the scripting text according to the design
document Const fnScriptLib = "$ScriptLib" Const fnDBScript = "$DBScript" Const fnFormGlobalScript = "$Script" Const fnFormScript = "$$FormScript" Const fnViewGlobalScript = "$ViewGlobalScript" Const fnViewScript = "$ViewScript" Dim DesignDocs() As NotesDocument Dim fns As Variant Dim ErrMsg As String Dim x As Long, updated As Boolean For x = Lbound(DocTypes) To Ubound(DocTypes) Gosub GetScriptFields If fns(0) = "" Then Goto GetNextType If Not GetDesignDocs(db, DocTypes(x), DesignDocs(), ErrMsg) Then
Goto GetNextType updated = False Forall doc In DesignDocs Forall fn In fns If doc.HasItem(fn) Then Call doc.RemoveItem(fn) updated = True End If End Forall If updated Then Print "Updating " & doc.GetItemValue("$Title")(0) Call doc.Save(True, False) End If End Forall GetNextType: Next Exit Sub '================================================== GetScriptFields: Redim fns(0) Select Case DocTypes(x) Case "SCRIPTLIBRARIES" Redim fns(0) fns(0) = fnScriptLib Case "DATABASESCRIPT" Redim fns(0) fns(0) = fnDBScript Case "FORMS", "SUBFORMS", "PAGES" Redim fns(0 To 1) fns(0) = fnFormGlobalScript fns(1) = fnFormScript Case "VIEWS" Redim fns(0 To 1) fns(0) = fnViewGlobalScript fns(1) = fnViewScript Case "FOLDERS" Redim fns(0 To 1) fns(0) = fnViewGlobalScript fns(1) = fnViewScript Case Else 'not supported End Select Return End Sub '********************************************************** Private Function GetDesignDocs(db As NotesDatabase, Byval DesignDocType As
String, DesignDocs() As NotesDocument, ErrMsg As String) As Boolean Const LSI_THREAD_PROC = 1 Dim nc As NotesNoteCollection Dim notedoc As NotesDocument Dim nid As String Dim TypeNotFound As Boolean Dim msgNotFound As String Dim x As Long, y As Long msgNotFound = "No design documents found from type " & DesignDocType Set nc = db.CreateNoteCollection(False) Call SelectDesignTypeCollection(nc, DesignDocType, TypeNotFound) If TypeNotFound Then ErrMsg = msgNotFound Exit Function Else Call nc.BuildCollection End If nid = nc.GetFirstNoteId y = 0 Redim DesignDocs(y) For x = 1 To nc.Count Set notedoc = db.GetDocumentByID(nid) If notedoc Is Nothing Then Goto GetNextNote Redim Preserve DesignDocs(y) Set DesignDocs(y) = notedoc y = y + 1 GetNextNote: nid = nc.GetNextNoteId(nid) Next If DesignDocs(0) Is Nothing Then ErrMsg = msgNotFound Else GetDesignDocs = True End If End Function '********************************************************** Private Sub SelectDesignTypeCollection(nc As NotesNoteCollection, Byval DocType
As String, NotFound As Boolean) Select Case Ucase(DocType) Case "ACTIONS" nc.SelectActions = True Case "AGENTS" nc.SelectAgents = True Case "DATABASESCRIPT" nc.SelectDatabaseScript = True Case "DATACONNECTIONS" nc.SelectDataConnections = True Case "FOLDERS" nc.SelectFolders = True Case "FORMS" nc.SelectForms = True Case "FRAMESETS" nc.SelectFramesets = True Case "HELPABOUT" nc.SelectHelpAbout = True Case "HELPINDEX" nc.SelectHelpIndex = True Case "HELPUSING" nc.SelectHelpUsing = True Case "ICON" nc.SelectIcon = True Case "IMAGERESOURCES" nc.SelectImageResources = True Case "FORMULA" nc.SelectionFormula = True Case "JAVARESOURCES" nc.SelectJavaResources = True Case "MISCCODEELEMENTS" nc.SelectMiscCodeElements = True Case "MISCFORMATELEMENTS" nc.SelectMiscFormatElements = True Case "INDEXELEMENTS" nc.SelectMiscIndexElements = True Case "NAVIGATORS" nc.SelectNavigators = True Case "OUTLINES" nc.SelectOutlines = True Case "PAGES" nc.SelectPages = True Case "REPLICATIONFORMULAS" nc.SelectReplicationFormulas = True Case "SCRIPTLIBRARIES" nc.SelectScriptLibraries = True Case "SHAREDFIELDS" nc.SelectSharedFields = True Case "STYLESHEETRESOURCES" nc.SelectStyleSheetResources = True Case "SUBFORMS" nc.SelectSubforms = True Case "VIEWS" nc.SelectViews = True Case Else NotFound = True End Select End Sub

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

Dig Deeper on Lotus Notes Domino Database Management

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials'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 ...