Skip to content

Flow Name: Order Summary Creation - Manual Orders

Last Updated: 2025-10-22 Source Code: Order_Summary_Creation_Manual_Orders.flow-meta.xml

API Name: Order_Summary_Creation_Manual_Orders Status: Active Type: Modified Standard Trigger: Record-Triggered Flow - After Save on Order (Async After Commit)

Business Purpose

This flow automatically creates Order Summary records for manual orders when they reach "Ready for Activation" status. It handles the complete order-to-order-summary conversion process including order delivery group creation, order item setup, order activation, and order summary generation.

Process Flow

1. Validation and Setup

  • Checks if OrderSummary already exists for this Order (prevents duplicates)
  • Validates order has at least one OrderItem
  • Retrieves "Digital Shipping" OrderDeliveryMethod for delivery setup

2. Order Delivery Group Creation

Creates OrderDeliveryGroup with: - Delivery address from account's PersonMailing address - Company information (handles person vs business account names) - Associates with Digital Shipping delivery method - Links to current order

3. Order Item Processing

  • Loops through each OrderItem in the order
  • Updates each OrderItem with:
  • OrderDeliveryGroupId (links to created delivery group)
  • Type: "Order Product"
  • Description: Product2.Name
  • TotalLineAmount: Quantity × UnitPrice
  • Performs bulk update of all OrderItems

4. Order Activation

Updates Order record with: - Billing and shipping addresses from account (formula-based for person vs business accounts) - OrderedDate: Current datetime - Status: "Pending Payment"

5. Order Summary Creation

  • Configures createOrderSummary input:
  • orderId: Current order ID
  • orderLifeCycleType: "Managed"
  • businessModel: "B2C"
  • Executes createOrderSummary action
  • Updates order with Line_Product_Name__c (first product name) and Order_Summary__c (OrderSummary ID)
  • Sets OrderSummary status to "Pending Payment"

6. Completion

  • Creates Page_Refresher__e platform event for UI refresh
  • Returns OrderSummary number for reference
📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: Order Status Changed<br/>to Ready for Activation]) --> CheckDupe{OrderSummary<br/>Already Exists?}

    CheckDupe -->|Yes| End([End])
    CheckDupe -->|No| CheckItems{Order Items<br/>Exist?}
    CheckItems -->|No| End

    CheckItems -->|Yes| GetDelivery[Get Digital Shipping<br/>Delivery Method]
    GetDelivery --> CreateGroup[Create OrderDeliveryGroup<br/>with Address]

    CreateGroup --> LoopItems[Loop Through<br/>Order Items]
    LoopItems --> UpdateItems[Update OrderItem:<br/>DeliveryGroup, Type,<br/>Description, TotalLineAmount]

    UpdateItems --> UpdateOrder[Update Order:<br/>Addresses, OrderedDate,<br/>Status=Pending Payment]
    UpdateOrder --> CreateSummary[Create OrderSummary<br/>Managed, B2C]

    CreateSummary --> LinkSummary[Update Order with<br/>OrderSummary ID and<br/>Line Product Name]
    LinkSummary --> SetStatus[Set OrderSummary<br/>Status=Pending Payment]

    SetStatus --> PublishEvent[Publish Page_Refresher<br/>Platform Event]
    PublishEvent --> End

    style Start fill:#e1f5ff
    style CheckDupe fill:#fff4e1
    style CheckItems fill:#fff4e1
    style GetDelivery fill:#f0e1ff
    style CreateGroup fill:#ffe1e1
    style LoopItems fill:#e1ffe1
    style UpdateItems fill:#ffe1e1
    style UpdateOrder fill:#ffe1e1
    style CreateSummary fill:#ffe1e1
    style LinkSummary fill:#ffe1e1
    style SetStatus fill:#ffe1e1
    style PublishEvent fill:#ffe1e1
    style End fill:#e1f5ff

Key Business Rules

  • Only processes orders with Status = "Ready for Activation"
  • Only processes Manual_Order__c = true OR Renewal_Order__c = true
  • Evaluation criteria: Record is changed to meet criteria (not every update)
  • Prevents duplicate OrderSummary creation
  • Requires at least one OrderItem to proceed
  • Uses formula-based address population: Person accounts use PersonMailing fields, Business accounts use Billing fields
  • Company name logic: N/A for person accounts, AccountName for business accounts
  • Order item TotalLineAmount calculation: Quantity × UnitPrice
  • Hard-coded values: "Digital Shipping" delivery method, "Managed" lifecycle type, "B2C" business model
  • Execution: Async after commit (runs after initial transaction completes)

Dependencies

  • Salesforce Order Management licensing and configuration
  • Order object with custom fields: Manual_Order__c, Renewal_Order__c, Line_Product_Name__c, Order_Summary__c
  • OrderDeliveryMethod record with Name = "Digital Shipping"
  • Account object with PersonMailing and Billing address fields
  • Platform Events: Page_Refresher__e object
  • createOrderSummary action (Salesforce Order Management API)

Changes

Template Source: runtime_commerce_oms__Create_OS (based on standard Order Management template)

Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • Validate that Salesforce Order Management is properly licensed and configured
  • Ensure "Digital Shipping" OrderDeliveryMethod exists before go-live
  • Add validation for null/blank address fields before creating OrderDeliveryGroup
  • Implement comprehensive error handling for createOrderSummary action failures

HIGH - Address Soon After Go-Live

  • Add fault handling for all database operations and OMS actions
  • Implement retry logic for failed OrderSummary creation
  • Add logging for troubleshooting order conversion failures
  • Validate financial calculations (TotalLineAmount) handle edge cases correctly

MEDIUM - Future Enhancement

  • Make delivery method name configurable via Custom Metadata instead of hard-coded
  • Allow business model and lifecycle type configuration
  • Add support for complex pricing scenarios (discounts, taxes, adjustments)
  • Consider standardized address objects instead of formula-based population
  • Add support for additional order types beyond manual and renewal

LOW - Monitor

  • Track OrderSummary creation success rates
  • Monitor for orders stuck in "Ready for Activation" status
  • Alert on Order Management API failures
  • Dashboard for order summary creation volume and timing
  • Verify async processing completion times

Maintenance Notes

  • Complexity: High - involves Order Management API integration and multi-step data transformation
  • Template source: runtime_commerce_oms__Create_OS indicates based on standard Salesforce template
  • Async after commit processing means OrderSummary creation happens after order save completes
  • Formula-based address handling requires careful null checking and validation
  • Financial calculation simplicity (quantity × unit price) may not handle all pricing scenarios
  • Review quarterly to ensure OMS configuration remains aligned with business processes
  • Test thoroughly when making changes to order, order item, or account structures