按钮事件字段设置问题 - Lotus Script
我的表单中有一个按钮,可以显示视图文档的选择列表...我的问题是无法将选择列表中的选定文档设置到“Superior1”字段中。请帮助我。以下是单击事件脚本...
Sub Click(Source As Button)
Dim session As New notessession
Dim view As NotesView
Dim view1 As notesview
Dim doc As notesdocument
Dim db As Notesdatabase
Dim Overdb As notesdatabase
Dim og As String
Dim Sup As String
Set db=session.CurrentDatabase
Set Overdb=session.GetDatabase(gsserver, "Master\\ASEAN_Staff.nsf")
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim picklist As Variant
Set uidoc = workspace.CurrentDocument
og = uidoc.FieldGetText("OfficeGroup_Key")
picklist = workspace.PickListStrings( PICKLIST_CUSTOM,_
False,_
gsserver,_
"Master\\ASEAN_Staff.nsf",_
"x_asean_superior1",_
"Select Name",_
"Choose",_
1,_
og )
If Isempty(picklist) Then
Exit Sub
Else
Set view = Overdb.GetView("x_asean_Superior1")
Set doc = view.GetdocumentByKey(picklist, False)
Sup=doc.ColumnValues(1)
Call uidoc.FieldSetText("Superior1", Sup)
End If
End Sub
如果我有任何错误,请纠正我...从选项列表中选择文档时..第一个文档被设置到“Superior1”字段中...我选择的 wateva 未在该字段中设置。 ..
I have a button in a form that on brings a picklist of a view's documents... My issue is am not able to set the selected document from the picklist into a field "Superior1".. plz help me.. following is the click event script...
Sub Click(Source As Button)
Dim session As New notessession
Dim view As NotesView
Dim view1 As notesview
Dim doc As notesdocument
Dim db As Notesdatabase
Dim Overdb As notesdatabase
Dim og As String
Dim Sup As String
Set db=session.CurrentDatabase
Set Overdb=session.GetDatabase(gsserver, "Master\\ASEAN_Staff.nsf")
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim picklist As Variant
Set uidoc = workspace.CurrentDocument
og = uidoc.FieldGetText("OfficeGroup_Key")
picklist = workspace.PickListStrings( PICKLIST_CUSTOM,_
False,_
gsserver,_
"Master\\ASEAN_Staff.nsf",_
"x_asean_superior1",_
"Select Name",_
"Choose",_
1,_
og )
If Isempty(picklist) Then
Exit Sub
Else
Set view = Overdb.GetView("x_asean_Superior1")
Set doc = view.GetdocumentByKey(picklist, False)
Sup=doc.ColumnValues(1)
Call uidoc.FieldSetText("Superior1", Sup)
End If
End Sub
Plz correct me if I am wrong anywhr... On selecting a document from the picklist.. the 1st document gets set into the field "Superior1"... wateva i selected is not getting set in the field...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从 PickListStrings 返回时的 picklist 是一个字符串数组。要在 GetDocumentByKey 中使用其值,请使用 picklist(0) 来获取第一个条目。
picklist when returned from PickListStrings is an array of strings. To use its value in GetDocumentByKey use picklist(0) to get the first entry.
当您使用最后一个
PickListStrings
参数将选择列表对话框中的文档限制为某个类别时,您永远不会将 1 指定为倒数第二个参数,因为您不甚至可以在对话框中看到类别(第一列)。相反,要获取第一个可见列,请使用 2。
此外,当使用
GetdocumentByKey
实现此目的时,请将第二个参数设置为True
(您需要精确匹配文档,而不是模糊搜索)。有一件事我不明白,如果你只是想这么做
为什么不直接从 PickListStrings 传输值呢?只需在 PickListStrings 中指定列(在对话框中可见)编号,如下所示:
当您已经可以使用 PickListStrings 获取其任何(查看列)值时,我不明白为什么要进行查找来获取相同的文档?
When you're using last
PickListStrings
parameter to restrict documents in a pick list dialog to a category, you never specify 1 as the second to last param, since you don't even see the category (which is the first column) in a dialog.Instead, to get first visible column use 2.
Also, when using
GetdocumentByKey
for this purpose, set second parameter toTrue
(you want exact match document, not fuzzy search).One thing I don't understand, if you're just trying to
why don't you simply transfer the value directly from PickListStrings. Just specify the column (visible in dialog) number in the PickListStrings, like this:
I don't understand why are you doing lookup to get the same document, when you can already get any of its (view column) values using PickListStrings?
对 mbonaci 答案的一个小补充 - 请注意,如果用户按“取消”,对话框将返回一个
EMPTY
变体。在这种情况下,尝试访问picklist(0)
将导致错误。为了解决这个问题,请检查IsEmpty(picklist)
是否为 True,如果为 True,则执行适当的操作(Exit Sub
等)。One small addition to mbonaci's answer - Note that if the user presses "Cancel" the dialog returns an
EMPTY
variant. In this case trying to accesspicklist(0)
would result in an error. To account for this, check ifIsEmpty(picklist)
and if True, do what's appropriate (Exit Sub
, etc.).