In Designer mode

Let us implement the confirmation window.

  1. Open the configuration property palette and look at the Modality usage mode property (fig. 26.3).


    Fig. 26.3. Modality usage mode configuration property

    It has the default value "Do not use", which is the recommended mode.

    An attempt to open a modal window in this mode returns an error.

    To avoid this error, let us use the nonmodal method ShowQueryBox() instead of the modal method DoQueryBox() in the Pick command handler.

    For each modal method, the platform has a matching nonmodal method that does not block script execution and does not use a modal window. Nonmodal methods do not cause any web application issues. They have the following specifics:
    • Method names begin with Show or Begin. Examples: ShowQueryBox() instead of DoQueryBox(), BeginPutFile instead of PutFile, and so on.
    • The first parameter is a NotifyDescription object that points to the module procedure to be executed once the user input is received.
    • There is no return value. Istead, the user input is passed to the module procedure described by the NotifyDescription object.
    Learn more! The full mapping between modal and nonmodal methods is available in section "Forms. Different approaches to modality. Method mapping" of 1C:Enterprise Developer Guide.
  2. Add the script shown in listing 26.7 to the GoodsReceipt document form module.

    Listing 26.7. Pick button click handler with a confirmation dialog box

    &AtClient
    Procedure PickConfirmation(Command)
     
        Notification = New NotifyDescription("PickCompletion", ThisObject);
        ShowQueryBox(Notification, "Do you want to pick materials and services?", 
            QuestionDialogMode.YesNo);
     
    EndProcedure
     
    &AtClient
    Procedure PickCompletion(Result, Parameters) Export
     
        If Result = DialogReturnCode.Yes Then
            FormParameters = New Structure ("MultipleChoice", True);
            OpenForm("Catalog.MaterialsAndServices.ChoiceForm", FormParameters, 
                Items.Materials);
        EndIf
     
    EndProcedure
    The PickConfirmation procedure first creates a NotifyDescription object. The first parameter of the object constructor is the name of the notification handler procedure, which is executed once the user input is received. The second parameter is the name of the module where the procedure is located.

    A notification handler procedure can be stored in a managed form module, in a nonglobal common client module, or in a command module. In this example the procedure is located in the module of this form, which is described by the ThisObject reference.

    Then a nonmodal method ShowQueryBox() is executed. It displays the confirmation dialog box. The method accepts the NotifyDescription object as a parameter. This object points to the module procedure (PickCompletion) that is executed once a user makes a selection in the blocking dialog box.

    A notification handler procedure must be declared as an export procedure (using the Export keyword). The Result parameter contains the user answer. If the user answer is Yes, the procedure opens the materials and services list for picking.

    Let us replace the old Pick command handler with a new one.
  3. In the Pick command property palette, in the Action field, select the PickConfirmation procedure (fig. 26.4).


    Fig. 26.4. Specifying the action for the Pick command
Next page: In 1C:Enterprise mode
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.