New Purchase Page - Logic for Data Variables

New Purchase Page - Logic for Data Variables

  1. Go to Variables > DATA VARIABLES

  1. Add 2 data variables: A_ProductBasicText and Customers
  • Select SAVE

Note

: Please make sure that you have same data variable names in your screen:

  1. Select Customers1 data entity. Select the [X] icon under Filter condition.

  1. Select Object with Properties

  1. Add a condition:
    • Property: customerNumber.
    • Condition type: equal.
    • Select the ‘123’ icon under Compared value

  1. Go to Formula > Select into the Formula field

  1. Enter the formula below and Save the formula afterwards
Code Snippet
1
INTEGER(params.SelectedCustomerNumber)

  1. Save the condition

  1. Switch to User Interface.

  2. Drag & Drop the UI Components with the following order:

    • Dropdown field
    • Input field
    • Button

  1. Switch to VARIABLES > PAGE VARIABLES

  2. Create 2 Page Variables

    • Variable 1: Name: PurchaseValue Variable Value type: number
    • Variable 2: Name SelectedProduct Value type: text

  1. Select Save

  2. Switch back to User Interface then:

    • Select Dropdown field.
    • Rename the Label text: Select Product.
    • Select the ‘[ ]’ icon under Option list.

  1. Go to Formula

  2. Enter the formula below

Code Snippet
1
MAP(data.A_ProductBasicText1, {label:item.Product, value:item.Product})
  1. Save the Formula

  1. Select the X under Selected value

  1. Go to Data and Variables > Page variable > SelectedProduct > select Save

  2. Select Input field and Rename label: Purchase Value

  3. Select the ‘X’ icon under Value

  1. Go to Data and Variables > Page variable > PurchaseValue

  2. Select Save

  1. Select Button > Rename label: Add Points!

  2. Open Logic Canvas

  1. Drag & Drop the logic components below to create the logic and join each component.

    • Create record
    • Alert
    • Navigate back
  2. Select Save

  1. Select Create record function > Select the data entity Purchases and Save.

  2. Select the Custom Object

  1. Select the ABC icon under ID > Formula

  2. Select the Formula bar.

  1. Enter the following formula and Save:
Code Snippet
1
GENERATE_UUID()

  1. Select the [X] icon under customer_ID > Formula > Create formula

  1. Enter the following formula and Save:
Code Snippet
1
data.Customers1[0].ID

  1. Select the [X] icon under purchaseValue > Formula > Create formula

  1. Enter the following formula and Save:
Code Snippet
1
INTEGER(pageVars.PurchaseValue)

  1. Select the [X] icon under selectedProduct > Data and Variables > Page Variable > SelectedProduct

  1. Save the window

  1. Select Alert component > Select the ABC icon under Dialog title > Formula

  1. Copy and Paste (as plain text) the formula below > Save
Code Snippet
1
data.Customers1[0].name + " has successfully earned " + outputs["Create record"].response.rewardPoints + " points!"