How do I populate a list box with all views from an external db

I have a form that contains these fields:dbName

server

filename

viewNames

fieldNames

I’m using an action button to do a @Prompt([ChooseDatabase]) to allow the user to select the database they want to work with. After selecting the database, the dbName, server and filename fields are updated properly.

Question is this…how do I also populate the “viewNames” listbox field with all the views & folders contained in the selected database, then based on which view/folder they select, populate all the fields available in that database?

Subject: how do I populate a list box with all views from an external db

one way to do this is on your existing event of the dB is to write some script to open up the dB, you can then get a handle of the views of the dB, and populate the field.

the same sort of logic would be done after they have selected the form.

if you go to the sandbox and look up export to excel you will see an entry for exporting to excel or an ascii file. i have all the logic in there to pull the field names for a form.

John

Subject: how do I populate a list box with all views from an external db

I’m not certain how to populate the fields available, as I’m not sure exactly what you mean by that. But I do have a database that does everything up to that point - users get a dropdown of servers to choose from, then when they choose the server, they get another dropdown of databases, then a dropdown of views in the database.

This is kind of messy to explain, but I’ll try. If you want me to send you the database itself, leave your email address.

Form contains four fields: serverChoice, dbChoice, viewList, and viewChoice.

serverChoice properties:

Combobox

Use formula for choices

Formula:

@DbColumn(“”;“myservername”:“names.nsf”;“Servers”;3)

Refresh fields on keyword change

Refresh choices on document refresh

dbChoice properties:

Dialog list (although could be combobox - just did this because of space constraints)

Allow multiple values

Use formula for choices

Formula:

@DbLookup( “” : “NoCache” ; serverChoice : “catalog.nsf” ; “ByServer” ; serverChoice ; 3 ) + " | " + @DbLookup( “” : “NoCache” ; serverChoice : “catalog.nsf” ; “ByServer” ; serverChoice ; 2 )

Refresh fields on keyword change

Refresh choices on document refresh

Hide-when: serverChoice=“”

onChange:

Sub Onchange(Source As Field)

On Error Goto errhand

Dim w As New notesuiworkspace

Dim uid As notesuidocument

Dim thisDoc As notesdocument

Dim chosenDB As notesdatabase

Dim viewList As notesitem



Set uid = w.currentdocument

Set thisDoc = uid.document

Set viewList = thisDoc.getfirstitem("viewList")

Set chosenDB = New NotesDatabase( "", "")	



Call chosenDB.open(thisdoc.serverChoice(0), thisdoc.dbChoice(0) )



Forall v In chosenDB.views

	Call viewList.appendToTextList(v.Name)

End Forall

Call uid.Refresh	



Exit Sub

errhand:

Msgbox "onchange error at line " & Erl & ": " & Error

Exit Sub	

End Sub

viewList properties:

Text, multivalue

Computed

Compute after validation

Default formula: viewList

Hide-when: 1 (or however you indicate hide always)

viewChoice properties:

Dialog list

Use formula for choices

Formula:

viewList

hide-when: dbChoice=“” & viewList=“”