In the project that I’m working now I needed a way to select multiple entries from a list and copy them to another list.
To do this I created a form which contains two ListBox fields called listA and listB and a Button field named To. The entries of the two lists are computed using two hidden fields toListA and toListB. In order to have multiple values two hidden fields should have the option “Allow multiple values” set.
Values for the listA are taken from column number 10 of a view called “All Entries” using this formula:
@DbColumn( “Notes”: “nocache “;””;” All Entries)”, 10)
The ListBox field has a property called values which keeps only the selected entries (checked). ListBox field can also have a group of two values, separated by |, for each entry in the list . The first value is that displayed in the list. The second value is hidden. In this case, when some entries are selected, the values property returns the second value, the hidden one.
When the To button is pushed, a script written in Lotus Script is executed, and the selected entries from the listA are copied to listB. The entries that exist in listB are not copied.
Sub Click(Source As Button) Dim session As New NotesSession Dim db As NotesDatabase Dim uiworkspace As New NotesUIWorkspace Dim doc As NotesDocument Dim uidoc As NotesUIDocument Set db = session.CurrentDatabase Set uidoc = uiworkspace.CurrentDocument Set doc = uidoc.Document Set listA = doc.GetFirstItem("listA") Set toListA = doc.GetFirstItem("toListA") If doc.listA(0) = "" Then Messagebox "You must select an entry first." Else Forall v In listA.Values If toListA.contains(v) Then Messagebox( v + " entry already exists. Will not be added.") Else toListA.AppendToTextList(v) End If End Forall doc.listA = "" doc.listB = "" Call uidoc.Refresh End If End Sub |
After you copy the entries, in the script the fields listA and listB are set to “” so that the selected entries to remain unchecked.
If there is a need to delete a particular entry or all entries in listB I added two buttons Remove and Remove All.
This is the script for Remove button:
Sub Click(Source As Button) Dim session As New NotesSession Dim db As NotesDatabase Dim uiworkspace As New NotesUIWorkspace Dim doc As NotesDocument Dim uidoc As NotesUIDocument Dim toListA As NotesItem Dim textList As Variant Dim outList As Variant Set db = session.CurrentDatabase Set uidoc = uiworkspace.CurrentDocument Set doc = uidoc.Document Set toListA = doc.GetFirstItem("toListA") If Not (toListA Is Nothing) Then Forall v In toListA.Values textList = doc.GetItemValue("toListA") If (Ubound(textList) > 0) Then Redim outList(Ubound(textList)-1) As Variant Else Redim outList(0) As Variant End If For i = 0 To Ubound(textlist) If textList(i) <> v Then outList(j) = textList(i) End If Next Call doc.ReplaceItemValue("toListA",outList) End Forall End If Call uidoc.Refresh End Sub |
and the script for Remove All:
Sub Click(Source As Button) Dim session As New NotesSession Dim db As NotesDatabase Dim uiworkspace As New NotesUIWorkspace Dim doc As NotesDocument Dim uidoc As NotesUIDocument Set db = session.CurrentDatabase Set uidoc = uiworkspace.CurrentDocument Set doc = uidoc.Document doc.toListA = "" Call uidoc.Refresh End Sub |
References:
IBM Lotus Domino and Notes Information Center
Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.
[…] a previous article I wrote on how to work with Lotus Notes ListBox fields. Unfortunately these type of fields have a […]
February 19, 2010 at 11:45 amValuable info. Lucky me I found your site by accident, I bookmarked it.
June 24, 2010 at 4:46 pm