Create a Flow for Purchases
Create a Flow for Base Points
As part of the accrual process, Linda creates a flow that calculates the points (qualifying and non-qualifying) to credit based on the tier and the transaction amount. She creates a record-triggered flow because she wants the flow to launch when a transaction journal is created.
Here’s what she does.
- Click , and select Setup.
- Enter
Flows
in the Quick Find box, and select Flows.
- Click New Flow.
- Make sure Start from Scratch is selected, and click Next.
- Select Record-Triggered Flow.
- Click Create and provide the following details.
- Object: Transaction Journal
- Configure Trigger: A record is created
- Condition Requirements: All Conditions are Met (AND)
- Field: Status
- Operator: Equals
- Value: Pending
- Optimize this flow for: Actions and Related Records
- Click to close the panel.
Select the Layout
In the button bar, change the Auto-Layout setting to Free-Form.
Create the Resources
Before Linda can add the elements required to run this flow, she creates the resources that she will reference in the flow.
- On the Manager tab, click New Resource.
- Provide the following details.
- Resource Type: Variable
- API Name:
TransactionAmount
- Data Type: Number
- Decimal Places:
2
- Default Value: select Triggering TransactionJournal, then Transaction Amount
- Click Done.
- Linda repeats steps 1 to 3 to create the remaining resources with the following details.
Resource Type |
API Name |
Data Type |
Decimal Places |
Default Value |
Formula |
Available for Input |
Available for Output |
---|---|---|---|---|---|---|---|
Variable |
Multiplier |
Number |
2 |
- |
- |
- |
- |
Formula |
BasePointsToCredit |
Number |
2 |
- |
{!TransactionAmount}*{!Multiplier} |
- |
- |
Define the Rules
Linda now adds all the elements required for the flow. She first uses a Decision element to filter all the transaction journals related to the Inner Circle loyalty program, with the journal subtype as Purchase.
- On the Elements tab, drag the Decision element onto the canvas.
- For Label, enter
CheckEntryConditions
.
- Provide the following details.
- Outcome Details Label:
EntryConditions
- Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
- Resource: select Triggering TransactionJournal, then Loyalty Program ID (the one with a > at the end of the line), then Program Name
- Operator: Equals
- Value:
Cloud Kicks Inner Circle
- Click Add Condition and provide the following details.
Resource
Operator
Value
Triggering TransactionJournal > Journal Type ID (the one with a > at the end of the line) > Program Name
Equals
Accrual
Triggering TransactionJournal > Journal Subtype ID (the one with a > at the end of the line) > Program Name
Equals
Purchase
- Click Done.
She then uses the Action element to get details of member tiers.
- On the Elements tab, drag the Action element onto the canvas, and provide the following details.
- Filter by: Loyalty
- Action: Get Tier
- Label:
GetCurrentTier
- Program: Cloud Kicks Inner Circle
- Tier Group: Inner Circle Tier Group
- Member ID: $Record > MemberId
- Click Done.
Next, she adds another Decision element. This evaluates which tiers the members belong to.
- Drag the Decision element onto the canvas.
- For Label, enter
CheckCurrentTier
.
- Provide the following details.
- Outcome Details Label:
PlatinumAndDiamond
- Condition Requirements to Execute Outcome: Any Condition Is Met (OR)
- Resource: Outputs from GetCurrentTier > TierName
- Operator: Equals
- Value:
Platinum
- Click Add Condition.
- Resource: Outputs from GetCurrentTier > TierName
- Operator: Equals
- Value:
Diamond
- Click the New Outcome icon () and provide the following details.
- Outcome Details Label:
GoldAndSilver
- Condition Requirements to Execute Outcome: Any Condition Is Met (OR)
- Resource: Outputs from GetCurrentTier > TierName
- Operator: Equals
- Value:
Gold
- Click Add Condition.
- Resource: Outputs from GetCurrentTier > TierName
- Operator: Equals
- Value:
Silver
- Click Done.
Linda then adds the Assignment element to assign a value to the variable. This element assigns the multiplier resource to each tier. Depending on which tier the member falls in, the points get multiplied. For example, if the member belongs to the Platinum tier, the system multiples the transaction amount by 2.
- Drag the Assignment element onto the canvas and provide the following details.
- Label:
MultiplierForPlatinumAndDiamond
- Variable: Multiplier
- Operator: Equals
- Value:
2
- Click Done.
- Repeat steps 1 and 2 to add an Assignment element for the other outcome with the following details.
- Label:
MultiplierForGoldAndSilver
- Variable: Multiplier
- Operator: Equals
- Value:
1
- Label:
Credit Qualifying and Non-qualifying Points
Linda adds action elements to the flow so that both qualifying and non-qualifying points get credited to members.
- On the Elements tab, drag the Action element onto the canvas, and provide the following details.
- Filter by: Loyalty
- Action: Credit Points
- Label:
CreditNonQualifyingPoints
- Program: Cloud Kicks Inner Circle
- Currency Type: Regular Points
- Recipient Member ID: $Record > MemberId
- Number of Points to Credit: BasePointsToCredit
- Journal ID: $Record > Id
- Click Done.
- Repeat steps 1 and 2 with the following values.
- Filter by: Loyalty
- Action: Credit Points
- Label:
CreditQualifyingPoints
- Program: Cloud Kicks Inner Circle
- Currency Type: Tier Points
- Recipient Member ID: $Record > MemberId
- Number of Points to Credit: $Record > TransactionAmount
- Journal ID: $Record > Id
Put the Flow Together
Linda must now connect all the elements using connectors to build the flow. This determines the order in which the flow is executed at run time.
- Connect the elements in the following sequence.
- The Start element to CheckEntryConditions (Decision)
-
CheckEntryConditions (Decision) to GetCurrentTier (Action), with the outcome selection being EntryConditions
-
GetCurrentTier (Action) to CheckCurrentTier (Decision)
-
CheckCurrentTier (Decision) to the two assignment elements MultiplierForPlatinumAndDiamond and MultiplierForGoldAndSilver, with outcome selections being PlatinumAndDiamond and GoldAndSilver respectively
- The two Assignment elements to CreditNonQualifyingPoints (Action)
-
CreditNonQualifyingPoints (Action) to CreditQualifyingPoints (Action)
- Click Save.
- Enter the Flow Label:
InnerCircleAccrualFlow
- Click Save.
- Click Activate.
This flow will run every time a transaction journal record is created. The flow will check the tier that the member belongs to, calculate the points based on the tier, and credit the qualifying and non-qualifying points.
Create a Transaction Journal
Let’s look at how points are credited and updated when a transaction is processed.
Adria Darby, a Platinum tier member, purchases a pair of shoes for $100. As soon as the transaction journal is created, Adria is credited with 200 non-qualifying points and 100 qualifying points. Linda creates a transaction journal to see this in action.
- In the Loyalty Programs tab, select the Cloud Kicks Inner Circle loyalty program.
- In the Cloud Kicks Inner Circle program record, click the Members And Partners tab.
- In the Loyalty Program Members related list, select CL001.
- On the Transaction Journals card, click New.
- Provide the following details.
- Journal Type: Accrual
- Journal Subtype: Purchase
- Activity Date: Current Date
- Journal Date: Current Date
- Status: Pending
- Loyalty Program: Cloud Kicks Inner Circle
- Transaction Amount:
100
- Click Save.
As soon as the record is created, the transaction journal status changes to Processed, and the Loyalty Ledgers card is updated with the points.
Linda navigates to the member’s record and in the Loyalty Member Currency card, she sees the non-qualifying and qualifying points balance updated. Note that you may need to refresh your page to see the updated points.
We’ve created a flow for purchases. In the next step, we’ll create an accrual flow for engagement activities.