【问题标题】:Is it possible to pass arguments in lotus notes dialog box是否可以在 Lotus Notes 对话框中传递参数
【发布时间】:2016-04-18 07:47:57
【问题描述】:

我有一个表单,其中包含两个名为“字段 1”和“字段 2”的字段以及一个名为“检查”的操作按钮。单击该操作按钮时,我想打开包含三个字段的对话框,这些字段应根据字段 2 值自动填充。如何实现?

感谢有人帮助我。

【问题讨论】:

    标签: lotus-notes lotusscript lotus-formula


    【解决方案1】:

    是的,这是可能的。 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”并根据其值填充对话框字段。然后它会显示一个对话框,您可以在其中更改这些值。

    如果您在对话框中按下“确定”(对话框接受),代码将显示您在对话框中更改的值。

    【讨论】:

    • 请说详细点好吗?因为我是这项技术的新手
    • @Sathish 请检查我的更新。我认为它回答了你的问题。
    • 很好的答案。但我不同意最后的“请注意”这句话:如果您只是将 DialogBox 的第四个参数设置为“False”而不是您的示例中的“True”,那么它也会返回新创建的字段,如文档状态: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.
    • @TorstenLink 是的,你是对的。修正了我的答案。谢谢。
    • @Sathish 不客气 :) 请接受答案(回答 upwote/downvote 箭头下方的绿色标记),以帮助其他用户稍后找到此答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多