|
|
|
|
|
|
|
|
|
|
|
|
|
|
Implementing dynamic drop-down menus using Domino and Internet Explorer (continued)
Save the form.
Step 5: Create the view containing the raw data Create a view and name it "lookupvalues".
The view should contain two columns.
Since this article is aimed at experts, I won't go into detail about how to create a view and populate it with data. Instead I'll show you how the finished view should look and you can set it up. It's shown in Figure D.
FIGURE D
 
The finished view should look like this. Roll over picture for a larger image.
Step 6: Create the agent Create an agent and name it the following:
WebQueryOpenAgent for demo form
|
Set the agent to be a "Shared agent".
Set the agent to run "Manually From Agent List".
Set the agent to "Run Once (@commands may be used)".
Set the "run" dropdown to "Lotuscript".
This is shown in Figure E.
FIGURE E
 
Set up your agent. Roll over picture for a larger image.
This agent is executed when the page is loaded. It goes to the view, grabs the columns, and returns them formatted as a JavaScript array.
Its output goes into a field on the form positioned inside a pair of <script> tags, thereby converting the contents of the view into a client side JavaScript array.
The final output of the agent will be JavaScript code that looks like this (you don't need to type this in anywhere for our demonstration, its just to help understand the agent):
//Array of options for dropdown fields;
var dropdownarray = ;
|
Here's some p-code to help understand what the agent does:
- Set up the various objects needed, clear the variables;
- Get the view;
- Set up a buffer - we'll put all our output into the buffer;
- Add the start of the JavaScript array structure to the buffer;
- Iterate through each of the view rows and add them to the buffer, structured as JavaScript array rows;
- Add the end of the JavaScript array structure to the buffer;
- Put the buffer into the tempJavaScriptarray field on the form.
Here's the code of the agent. Put it into the "Initialize" section of the agent:
Sub Initialize
' builds a JavaScript array of Manufacturers and models
' this gets used at the client for dynamically updating dropdown fields
' Set up required objects
Dim session As New NotesSession
Dim sourcedoc As NotesDocument
Set sourcedoc = session.DocumentContext
Dim sourceDb As NotesDatabase
Dim view As NotesView
Dim entry As NotesViewEntry
Dim vc As NotesViewEntryCollection
Dim tmpbuffer As String
Dim tmpManufacturer As String
Dim tmpmodel As String
Dim i As Integer
Set sourceDb = session.CurrentDatabase
Set view = sourcedb.getView("lookupvalues")
Set vc = view.AllEntries
tmpManufacturer = ""
tmpmodel = ""
tmpbuffer = ""
tmpbuffer = tmpbuffer + {//Array of options for dropdown fields; } + Chr ( 13 )
tmpbuffer = tmpbuffer + {var dropdownarray = [}
For i = 1 To vc.count
Set entry = vc.GetNthEntry( i )
tmpManufacturer = entry.ColumnValues(0)
tmpmodel = entry.ColumnValues(1)
' put a comma and a carriage return to separate array values
If i >1 And i =< vc.count Then
tmpbuffer = tmpbuffer + {,} + Chr ( 13 )
End If
' add each entry
tmpbuffer = tmpbuffer + {['} + tmpManufacturer + {'} + {,}
tmpbuffer = tmpbuffer + {'} + tmpmodel + {'} + {]}
Next i
' close off the array
tmpbuffer = tmpbuffer + {];} + Chr ( 13 )
tmpbuffer = tmpbuffer + Chr(13) + Chr ( 13 ) + Chr ( 13 ) + Chr ( 13 )
' shove the buffer into the field value on the form
sourcedoc.tmpJavaScriptarray = tmpbuffer
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Find unused Lotus Notes groups and clean up your address book
Have you ever wanted to get rid of old Lotus Notes groups that were cluttering up your address book, but you weren't sure if they were used? Find Unused Groups can help.
Find Unused Groups will check your ACL, mail, multi purpose and server groups to help you determine if they are used, and who uses them.
Learn how to easily clean up your address book. |
-- Advertisement --
Teamstudio Edition 25 has shipped
It's finally here! Now that Teamstudio Edition 25 has shipped, listen to our latest Tool Time audio program to find out what's changed. Updates to all your favorite Teamstudio tools will be discussed.
Plus, you'll get an introduction to Teamstudio Undo (formerly known as Teamstudio Snapper).
Tap here to get started! |
|
|
|
|
|
|
|
|
|
|