Sathish
Sathish

Reputation: 25

Is it possible to pass arguments in lotus notes dialog box

I have one form with two fields called "Field 1" and "Field 2" and one action button called "check". On click of that action button, i want to open dialog box with three fields which should get auto populate based on Field 2 value. How to achieve it?

Appreciate if anyone helps me.

Upvotes: 0

Views: 1768

Answers (1)

user784540
user784540

Reputation:

Yes, it is possible. There's a document parameter for NotesUIWorkspace.DialogBox(). Use this document to pass parameters to your dialog.


UPDATE

Assume you have a form with name "MyDialogForm" to represent your dialog.

It looks like that and contains 3 fields:

MyDialogForm

And you have a form with two fields and "Check" button:

TestForm

Put the following code to the "Click" event handler of your "Check" button:

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

This code reads "Field2" and populates dialog fields based on its value. Then it shows the dialog where you can change these values.

demo dialog

If you pressed OK in your dialog (dialog accepted), the code will show the values you have altered in dialog box.

Upvotes: 4

Related Questions