按钮事件字段设置问题 - Lotus Script

发布于 2024-10-20 18:53:43 字数 1150 浏览 2 评论 0原文

我的表单中有一个按钮,可以显示视图文档的选择列表...我的问题是无法将选择列表中的选定文档设置到“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

上课铃就是安魂曲 2024-10-27 18:53:43

从 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.

尬尬 2024-10-27 18:53:43

当您使用最后一个 PickListStrings 参数将选择列表对话框中的文档限制为某个类别时,您永远不会将 1 指定为倒数第二个参数,因为您不甚至可以在对话框中看到类别(第一列)。
相反,要获取第一个可见列,请使用 2

此外,当使用 GetdocumentByKey 实现此目的时,请将第二个参数设置为 True (您需要精确匹配文档,而不是模糊搜索)。

有一件事我不明白,如果你只是想这么做

将选择列表中选定的文档设置到字段“Superior1”

为什么不直接从 PickListStrings 传输值呢?只需在 PickListStrings 中指定列(在对话框中可见)编号,如下所示:

...
picklist = workspace.PickListStrings( PICKLIST_CUSTOM,_
False,_
gsserver,_
"Master\\ASEAN_Staff.nsf",_
"x_asean_superior1",_
"Select Name",_
"Choose",_
2,_
og ) 

Call uidoc.FieldSetText("Superior1", picklist(0))

当您已经可以使用 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 to True (you want exact match document, not fuzzy search).

One thing I don't understand, if you're just trying to

set the selected document from the picklist into a field "Superior1"

why don't you simply transfer the value directly from PickListStrings. Just specify the column (visible in dialog) number in the PickListStrings, like this:

...
picklist = workspace.PickListStrings( PICKLIST_CUSTOM,_
False,_
gsserver,_
"Master\\ASEAN_Staff.nsf",_
"x_asean_superior1",_
"Select Name",_
"Choose",_
2,_
og ) 

Call uidoc.FieldSetText("Superior1", picklist(0))

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?

烂人 2024-10-27 18:53:43

对 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 access picklist(0) would result in an error. To account for this, check if IsEmpty(picklist) and if True, do what's appropriate (Exit Sub, etc.).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文