Alexey Shabramov
Alexey Shabramov

Reputation: 788

LotusScript - How to select multiple values in multi-select ListBox programmatically

I am trying to select values in my ListBox using LotusScript. My code looks like this:

Forall role In docByUi.rolesList
        If entity.getRoles <> "" Then
            If Instr(1, entity.getRoles,role,5) Then
                resultRoles = resultRoles & role
            Else    
                resultRoles = resultRoles + Chr$(13) + Chr$(10)
            End If
        End If
    End Forall

    Call uiDoc.FieldSetText("rolesList", resultRoles)
    Call uiDoc.Refresh

But it's not working. I have no problems when I am trying to select first item, but I can not select more than one.

My list box has two items (and it will be more of them in future): enter image description here

Questions:

1. How to select ListBox items using LotusScript?

2. How can I choose which item to select, if the items count is more than two e.t.c.?

3. Can you please give some small example of this or any advise...

Thank you!

Upvotes: 1

Views: 561

Answers (1)

Dmytro Pastovenskyi
Dmytro Pastovenskyi

Reputation: 5419

Please declare variable [resultRoles] as an array.

Dim resultRoles As Variant

resultRoles = Split("") 'that will make variable array

Forall role In docByUi.rolesList
    If entity.getRoles <> "" Then
        If Instr(1, entity.getRoles,role,5) Then
            resultRoles = Arrayappend(resultRoles, role)
        End If
    End If
End Forall

resultRoles = Fulltrim(resultRoles) 'that will delete first empty element from array

Call uiDoc.Document.replaceitemvalue("rolesList", resultRoles) 'use NotesDocument instead
Call uiDoc.Refresh

Here is an clean example where on form I have only 1 field ListField with values [a, b, c] and 1 button that fill that field.

Dim ws As New notesuiworkspace
Dim uidoc As NotesUIDocument
Dim a As Variant

Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document

a = Split("b;c", ";")
Call doc.replaceitemvalue("ListField", a)

Нема за що.

Upvotes: 3

Related Questions