Skip to content

Flow Name: Order before update

Last Updated: 2025-10-17 Source Code: Order_before_update.flow-meta.xml

API Name: Order_before_update Status: Active Type: Modified Standard Trigger: Before Order update when Status changes to Pending Payment

Business Purpose

Identifies orders containing PAC products and timestamps when they enter Pending Payment status, enabling downstream automation for payment timeout processing. Works in tandem with the 24-hour timeout flow.

Process Flow

  1. Triggers before Order update
  2. Checks if Status field changed to "Pending Payment"
  3. Looks up OrderItems to detect PAC products:
  4. Filters for OrderItems with Is_PAC__c = true
  5. Gets first record only (existence check)
  6. Updates Order with:
  7. Includes_PAC_Products__c = true/false (based on whether PAC OrderItem found)
  8. Pending_Payment_Date__c = current date/time
📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: Order Update<br/>Before Save]) --> CheckStatus{Status Changed to<br/>'Pending Payment'?}

    CheckStatus -->|No| End([End])
    CheckStatus -->|Yes| GetPAC[Get PAC OrderItems:<br/>Where Is_PAC__c = true<br/>For this Order]

    GetPAC --> Calculate[Calculate Formulas:<br/>• includesPacProductsFormula = PAC OrderItem exists<br/>• now = current timestamp]

    Calculate --> UpdateOrder[Update Order:<br/>• Includes_PAC_Products__c = formula result<br/>• Pending_Payment_Date__c = now]

    UpdateOrder --> End([End])

    style Start fill:#e1f5ff
    style CheckStatus fill:#fff4e1
    style GetPAC fill:#f0e1ff
    style Calculate fill:#e1ffe1
    style UpdateOrder fill:#ffe1e1
    style End fill:#e1f5ff

Key Business Rules

  • Only executes when Status changes to "Pending Payment"
  • Sets timestamp using NOW() formula for precise time tracking
  • PAC detection formula: OrderItem.Id != null
  • Updates both Includes_PAC_Products__c checkbox and Pending_Payment_Date__c datetime
  • Operates in Before Save context for optimal performance

Dependencies

  • Objects: Order (standard), OrderItem (standard)
  • Fields:
  • Status (standard)
  • Includes_PAC_Products__c
  • Pending_Payment_Date__c
  • OrderItem.Is_PAC__c
  • Related Flows: Order_24_hours_after_pending_payment (consumes these fields)

Changes

No Pull Request references found in metadata.

⚠️ Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • No Error Handling: If OrderItem lookup fails, fields may not update correctly
  • Unclear PAC Definition: "PAC" is not documented - verify business requirements
  • Timestamp Accuracy: NOW() uses system timezone - may not match user expectations

HIGH - Address Soon After Go-Live

  • Overwrite Risk: If order goes to Pending Payment multiple times, timestamp is overwritten
  • Missing Validation: Doesn't verify that Pending Payment is a valid status for the order
  • No Null Check: Doesn't verify OrderItems exist before searching

MEDIUM - Future Enhancement

  • Audit Trail: Consider preserving original Pending_Payment_Date__c in a separate field
  • Multiple PAC Products: Currently just checks existence - might want to count how many
  • Error Logging: Log when PAC detection completes for troubleshooting

LOW - Monitor

  • Performance: OrderItem lookup in before-save trigger - monitor with large orders
  • Data Quality: Verify Includes_PAC_Products__c accurately reflects PAC presence
  • Edge Cases: Monitor orders that change status to Pending Payment multiple times

Maintenance Notes

Complexity: Low - Simple lookup and field update Review Schedule: Review when PAC product logic or order statuses change Paired Flow: Works with Order_24_hours_after_pending_payment - test both together Commerce Dependency: Part of order processing workflow - changes affect checkout flow Before-Save Context: Minimal DML impact, but changes affect record immediately