Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

LotusScript: Programming views in Notes/Domino 6 sidebar

[Back to "LotusScript: Programming views in Notes/Domino 6"]

LotusScript:Programming views in Notes/Domino 6 sidebar

The following is a code example for creating a new view.

Declarations
Dim db As NotesDatabase
Dim Templateview As NotesView
Dim UsersView As NotesView
Dim col1 As NotesViewColumn
Dim col2 As NotesViewColumn
Dim J As Integer
Dim K As Integer
Dim L As Integer
Dim allcols () As String
Dim checkviewname () As String

Sub Initialize 
   Dim s As New NotesSession
   Dim ws As New NotesUIWorkspace

   Set db = s.CurrentDatabase
   Set Templateview = db.GetView("MAIN")
   'Asks for name of new view
CHOOSENAME: 
   newviewname = Inputbox("Name for new view?",
                 "What do you wish to name this view?")
   If Trim(newviewname) = "" Then
   Messagebox "Stopping processing",,
              "You did not enter a name for the view."
   Exit Sub
   End If
'Check for existing view name
Redim Preserve checkviewname(Ubound(db.Views))
For L = 0 To Ubound(db.Views) 
   checkviewname(L) = db.Views(L).Name
   If checkviewname(L) = newviewname Then
   Messagebox "The view name you entered is already being used. 
               Please pick another." _ 
               ,,"View Name already in use"
         Goto CHOOSENAME
   End If
Next

   'Create new view with name from user input
   Set UsersView = db.CreateView(newviewname)
   'Remove default column created with view
   Call UsersView.RemoveColumn(UsersView.ColumnCount)
   
   'Find number of columns in Templateview
   I = Ubound(Templateview.Columns)
   Redim Preserve allcols(I)
   'Create an array of column titles to be used in prompt
   For J = 0 To I
   allcols(J) = Templateview.Columns(J).Title
   Next
   K = 1
   
Do 

   chosencol = ws.Prompt(Prompt_OKCancelList,"Choose column to insert", _
   "Select from list of column names.","",allcols)
   'Find column position
   For J =0 To Ubound(Templateview.Columns)
   If Templateview.Columns(J).Title = chosencol Then
   Set col1 = Templateview.Columns(J)
   End If
   Next
   Set col2 = UsersView.CopyColumn(col1, K)
   If col2.Position = 1 Then
   asksort = ws.Prompt(PROMPT_YESNO,"Sorting for first column?", _
   "Do you want to sort the first column?")
   If asksort = 1 Then 
             col2.IsSorted = True
   End If
   End If
   'Set the font color for the header
   col2.HeaderFontColor = COLOR_BLUE
   K= K+1
Loop While ws.Prompt(PROMPT_YESNO,"Additional columns?",
"Do you want to add another column to the view?") 

   Messagebox "View completed",,"Your view has been built."
   
End Sub