Loading
Decision Table
Design a Flow to Update Order Discounts (Example)

Design a Flow to Update Order Discounts (Example)

Design a flow that allows the decision table to evaluate all the Order records that don’t have a discount. The flow also updates the evaluated Order records with the discount percentage determined by the decision table.

Required Editions

Available in: Lightning Experience
Available in: Enterprise, Performance, and Unlimited Editions with Loyalty Management or Rebate Management
User Permissions Needed
To create a flow: Manage Flow
To invoke a decision table: Run Decision Tables
Note
Note Decision tables are also available as part of Business Rules Engine. If your org has Business Rules Engine enabled, see Decision Tables for Business Rules Engine.

Let’s say your company adds new Product records every week, so you schedule the flow to ensure that a discount percentage is added weekly for the new products.

  1. From Setup, in the Quick Find box, enter Flows, and then select Flows.
  2. Click New Flow.
  3. Select Scheduled-Triggered Flow as the flow type.
  4. From Start, click Set Schedule, and then select the timing.
    • Start Date: May 16, 2021
    • Set Time: 12:00 AM
    • Frequency: Weekly

    Then click Done. This setting ensures that the flow runs every week.

  5. Drag the Get Records element to the canvas, and then select these attributes.
    • Name: Get Order Records
    • Object: Order
    • Filter Product Records:
      • Condition Requirements: All Conditions Are Met (AND)
      • Field: Discount
      • Operator: Is Null
      • Value: True
    • How Many Records to Store: All records
    • Then click Done.

    Get Records element in flow.
  6. Drag the Loop element onto the canvas, and then select these attributes.
    • Name: Loop All Order Records
    • Collection Variable: {!Get_Order_Records}
    • Direction: First item to last item
    • Click Done.
    Loop element in a flow.
  7. Drag the Get Records element onto the canvas, and then select these attributes.
    • Name: Get Order Product Records
    • Object: Order Product
    • Filter Product Records:
      • Condition Requirements: All Conditions Are Met (AND)
      • Field: OrderId
      • Operator: Equals
      • Value: {!Loop_All_Order_Records.Id}
    • How Many Records to Store: Only the first record
    • Then click Done.

    Get Records element in flow.
  8. Drag the Get Records element onto the canvas, and then select these attributes.
    • Name: Get Product Records
    • Object: Product
    • Filter Product Records:
      • Condition Requirements: All Conditions Are Met (AND)
      • Field: Id
      • Operator: Equals
      • Value: {!Get_Order_Product_Records.Product2Id}
    • How Many Records to Store: Only the first record
    • Then click Done.

    Get Records element in flow.
  9. Drag the Action element onto the canvas, and then select these attributes.
    1. Select Decision Table as Category.
    2. Search and select the Decide Discount Percentage for Orders - Evaluate Order and Product Field Values decision table action.
      Select the decision table action that allows the decision table to provide outcomes for the values of the fields specified in the dataset link.
    3. Enter the name Evaluate Order Records.
    4. In the Order field, enter {!Loop_All_Order_Records}.
    5. In the Product field, enter {!Get_Product_Records}.
      Data Processing Engine custom action in a flow.
    6. Click Done.
  10. Drag the Update Records element onto the canvas, and then select these attributes.
    • Name: Update Order Records
    • How to Find Records to Update and Set Their Values: Specify conditions to identify records, and set fields individually
    • Object: Order
    • Filter Product Records:
      • Condition Requirements: All Conditions Are Met (AND)
      • Field: Id
      • Operator: Equals
      • Value: {!Loop_All_Order_Records.Id}
    • Set Field Values for the Product Records:
      • Field:Discount__c
      • Value: {!Evaluate_Order_Records.singleOutcome.Discount__c}
    Update Records action in a flow.
  11. Click Done.
  12. Connect all the elements: Get Order Records | Loop All Order Records | Get Order Product Records | Get Product Records | Evaluate Order Records | Update Order Records | Loop All Order Records.
    Complete flow diagram.
  13. Save your work, and then complete these fields.
    • Flow Name: Provide Discount Percentage for Order
    • Flow API Name: Provide_Discount_Percentage_for_Order
  14. Activate the flow.
Example
Example Here are the discount percentages that the decision table provides for Order records.

Example of a decision table output being populated.

 
Laster
Salesforce Help | Article