HowTo: Using Confirm method from Interop in Smart Devices API

Official Content
This documentation is valid for:

The Confirm method is a very useful user interaction feature that makes possible the execution of actions according to the users confirmation or denial of a message. This method will prompt a message dialogue with two buttons that the user should tap: The Yes button and the No button.
If this method is executed on a Composite command and the user confirms the prompted messag, the following actions in the Composite command are going to be executed,  otherwise the execution of the Composite command stops.
Also, this method accepts a VarChar(200) parameter that defines the message shown on the prompt dialogue.

In this article is shown an example of how this feature is used and it behaves depending on the selected option. For this purpose, the LightCRM (X Evolution 2) sample is going to be used.

How it works

Lets say it is needed to confirm the insertion of a meeting every time the user wants to. For that reason, the Confirm method is going to be called in the same Event that is used for inserting new meetings.

First, open the WorkWithDevicesMeeting and go to Section(General) Events section.

Using Confirm Method Events Section Example

This is the default Save event of a meeting:

Event 'Save'
    SDActions.Save()
EndEvent

… but as confirmation is needed by the user, the second step is to call for confirmation right before the Save action is executed:

Event 'Save'
    Composite
        Confirm("Confirm this meeting?")
        SDActions.Save()
    EndComposite
EndEvent

Note: The composite block was added because more than one action are going to be executed in the same event.

Alternatively, it is also available to call the Confirm method as a method of the Interop external object. For instance:

Event 'Save'
    Composite
        Interop.Confirm("Confirm this meeting?")
        SDActions.Save()
    EndComposite
EndEvent

And that is all, whenever the user tries to save a meeting, the application is going to prompt for confirmation of the user first.

Using Confirm method Screenshot 0 Flecha_der Using Confirm method Screenshot 1 Flecha_der Using Confirm method Screenshot 2

Considerations

As from GeneXus X Evolution 2 Upgrade 5 it is available to use the Confirm method as a function that returns True or False whether the user confirms or not the prompted message. The important fact of this is that in case of the user  denies the confirmation, the Composite command is still going to continue its execution.

For example:

Event 'Save'
    Composite
        &HasConfirmed = Interop.Confirm("Confirm this meeting?")

        If &HasConfirmed
            SDActions.Save()
        Else
            Msg("Your meeting was not saved")
        EndIf
    EndComposite
EndEvent

Note: It is needed to call the Confirm method from the Interop API to make this code work.
For instance, this line of code is not valid:

&HasConfirmed = Confirm("Confirm this meeting?")




Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.