K2BTools Tutorial - Exercise 8.5: Displaying a confirmation screen if the purchase exceeds $500

To do so, we will use the conditional confirmation feature. It allows you to decide, using a condition, whether to display a confirmation screen.

  1. Go to the Buy action and enter the value of the Confirm property in Conditional.
  2. Save.

Right-click on this action, select GoToEvent and see how an additional subroutine is displayed.

Tutorial_75_TreePreview
Tree Preview

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?"

Else

&ConfirmationRequired = False

EndIf

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.