2017-06-16 110 views
1

我想使用LotusScript在我的列表框中选择值。 我的代码如下所示:LotusScript - 如何以编程方式在多选列表框中选择多个值

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 

但它不起作用。当我尝试选择第一个项目时,我没有任何问题,但我无法选择多个项目。

我的列表框中有两个项目(这将是更多的人在未来): enter image description here

问题:

1.如何使用LotusScript选择列表框的项目?

2.如何选择项目数量是否超过两个e.t.c.?

3.能否请您给的这个或任何提醒一些小例子

谢谢!

回答

3

请将变量[resultRoles]声明为数组。

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 

下面是一个干净的例子,其中在形式I具有值[A,B,C]和1的按钮,填补字段仅1场ListField。

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) 

Намазощо。

+0

谢谢!您的解决方案完美运作Спасибо! :) –

相关问题