【发布时间】:2016-04-18 07:47:57
【问题描述】:
我有一个表单,其中包含两个名为“字段 1”和“字段 2”的字段以及一个名为“检查”的操作按钮。单击该操作按钮时,我想打开包含三个字段的对话框,这些字段应根据字段 2 值自动填充。如何实现?
感谢有人帮助我。
【问题讨论】:
标签: lotus-notes lotusscript lotus-formula
我有一个表单,其中包含两个名为“字段 1”和“字段 2”的字段以及一个名为“检查”的操作按钮。单击该操作按钮时,我想打开包含三个字段的对话框,这些字段应根据字段 2 值自动填充。如何实现?
感谢有人帮助我。
【问题讨论】:
标签: lotus-notes lotusscript lotus-formula
是的,这是可能的。 NotesUIWorkspace.DialogBox() 有一个 document 参数。使用此文档将参数传递给您的对话框。
更新
假设您有一个名为“MyDialogForm”的表单来表示您的对话框。
看起来像这样,包含 3 个字段:
您有一个包含两个字段和“检查”按钮的表单:
将以下代码放入“检查”按钮的“单击”事件处理程序中:
Sub Click(Source As Button)
Const DIALOG_FORM_NAME = "MyDialogForm"
Dim ws As New NotesUIWorkspace
Dim dialogBoxAccepted As Boolean
Dim dialogParamDoc As NotesDocument
Dim currentDocument As NotesDocument
Dim field2Value As String
Set currentDocument = ws.CurrentDocument.Document
field2Value = currentDocument.GetItemValue("Field2")(0)
'document created in-memory, but should not be saved
Set dialogParamDoc = New NotesDocument(currentDocument.ParentDatabase)
'populating dialog box fields
Call dialogParamDoc.ReplaceItemValue("DialogField1", "dialogField1 with: " + field2Value)
Call dialogParamDoc.ReplaceItemValue("DialogField2", "dialogField2 with: " + field2Value)
Call dialogParamDoc.ReplaceItemValue("DialogField3", "dialogField3 with: " + field2Value)
dialogBoxAccepted = ws.DialogBox(DIALOG_FORM_NAME,True , True, False, False , False , False, "My Dialog Title", dialogParamDoc, True)
If dialogBoxAccepted Then
'displaying values, entered/changed in dialog box
Msgbox dialogParamDoc.getItemValue("DialogField1")(0),,"DialogField1"
Msgbox dialogParamDoc.getItemValue("DialogField2")(0),,"DialogField2"
Msgbox dialogParamDoc.getItemValue("DialogField3")(0),,"DialogField3"
End If
End Sub
此代码读取“Field2”并根据其值填充对话框字段。然后它会显示一个对话框,您可以在其中更改这些值。
如果您在对话框中按下“确定”(对话框接受),代码将显示您在对话框中更改的值。
【讨论】:
noNewFields: Boolean. Optional. Specify True to not add fields that are on the dialog box form but not already contained in the underlying document. Otherwise, all dialog box fields are passed to the underlying document.