To do so, we will use the conditional confirmation feature. It allows you to decide, using a condition, whether to display a confirmation screen or not.
- Go to the Buy action and enter the value of the Confirm property to "Conditional".
Right-click on this action, select GoToEvent and see how an additional subroutine is displayed.
Open the subroutine.
This subroutine allows us to write the condition to determine if the confirmation will be displayed or not. In this subroutine, two variables will be returned.
&ConfirmationRequired: Whether it requires a confirmation.
&ConfirmMessage: Confirmation message.
To implement it, delete the code generated by default and type the following:
If &Total > 500
&ConfirmationRequired = True
&ConfirmMessage = "The total is " + &Total.ToString() + ". Are you sure?"
&ConfirmationRequired = False
|Subroutine code - Part 1
Try it at runtime.
Note that the action code didn’t have to be changed to implement the conditional confirmation. Instead, K2BWebPanelDesigner generated a subroutine to control this, keeping the same implementation of the subroutine associated with the action. K2BWebPanelDesigner generates the right encapsulation of the code so that the changes have no impact.