Skip to content

Flow Name: Cancel/Remove

Last Updated: 2025-01-08 Source Code: Cancel_Item.flow-meta.xml

API Name: Cancel_Item Status: Active Type: Standard Trigger: Manual/screen flow invocation from OrderSummary records

Business Purpose

This comprehensive Order Management System flow allows users to cancel order items before fulfillment through a guided multi-step process. It handles item selection, reason assignment, cancellation fees, previewing changes, processing cancellations, managing refunds, and determining if the entire order should be cancelled.

Process Flow

  1. Order Validation: Validates OrderSummary exists, is managed, and has cancellable items
  2. Item Selection: User selects which order items to cancel from available items
  3. Quantity & Reasons: User specifies quantities and cancellation reasons for selected items
  4. Fee Configuration: Optionally configure cancellation fees (if allowCancelFees = true):
  5. Create or find "Fee For Cancelations" product
  6. Set pricebook entries for fees
  7. Allow user to select which items incur fees and amounts
  8. Preview Changes: Display summary of all changes before submission
  9. Submit Cancellation: Execute cancellation using Salesforce OMS APIs
  10. Process Refunds: Handle excess funds and ensure refunds are processed
  11. Confirmation: Display success message and determine if entire order should be cancelled
📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: Screen Flow<br/>Launched from OrderSummary]) --> Validate{Order Valid?<br/>Managed &<br/>Has Cancellable Items}

    Validate -->|No| ErrorMsg[Display Error Message]
    Validate -->|Yes| SelectItems[Screen: Select Items to Cancel<br/>excluding Delivery Charges]

    ErrorMsg --> End([End])
    SelectItems --> QuantReasons[Screen: Enter Quantities<br/>and Cancellation Reasons]

    QuantReasons --> FeesCheck{Allow Cancel Fees?}

    FeesCheck -->|Yes| SetupFees[Create/Find Fee Product<br/>Set Pricebook Entries<br/>Screen: Select Fee Items & Amounts]
    FeesCheck -->|No| Preview

    SetupFees --> Preview[Screen: Preview Changes<br/>Items, Quantities, Reasons, Fees]

    Preview --> Submit[Submit Cancellation<br/>via OMS API]

    Submit --> ProcessRefunds[Process Refunds<br/>via ensureRefundsAsync API]

    ProcessRefunds --> AllCancelled{All Original Items<br/>Cancelled?}

    AllCancelled -->|Yes| CancelOrder[Update Order and<br/>OrderSummary Status<br/>to Cancelled]
    AllCancelled -->|No| Confirm

    CancelOrder --> Confirm[Display Success Message]

    Confirm --> End

    style Start fill:#e1f5ff
    style Validate fill:#fff4e1
    style ErrorMsg fill:#ffcccc
    style SelectItems fill:#fff4e1
    style QuantReasons fill:#fff4e1
    style FeesCheck fill:#fff4e1
    style SetupFees fill:#f0e1ff
    style Preview fill:#fff4e1
    style Submit fill:#ffe1e1
    style ProcessRefunds fill:#ffe1e1
    style AllCancelled fill:#fff4e1
    style CancelOrder fill:#ffe1e1
    style Confirm fill:#e1ffe1
    style End fill:#e1f5ff

Key Business Rules

  • Only works with managed OrderSummary records (not UNMANAGED)
  • Only processes items with QuantityAvailableToCancel > 0
  • Excludes "Delivery Charge" items from cancellation options
  • Cancellation fees are optional (controlled by allowCancelFees input parameter)
  • Creates standard "cancel_fees" product automatically if fees are enabled
  • If all original items are cancelled, the entire OrderSummary and related Order are marked as Cancelled
  • Automatic refund processing for excess funds from cancellations

Dependencies

  • OrderSummary and OrderItemSummary standard objects (Salesforce OMS)
  • Order standard object
  • Product2 and PricebookEntry standard objects (for cancellation fees)
  • Salesforce OMS Connect APIs (cancelOrderItemSummariesPreview, cancelOrderItemSummariesSubmit, ensureRefundsOrderSummaryAsync)
  • Managed order lifecycle (OrderLifeCycleType ≠ UNMANAGED)
  • User permissions for order management operations

⚠️ Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • OMS Dependency: Requires Salesforce Order Management System licenses and proper configuration
  • API Limits: Heavy use of OMS Connect APIs - monitor governor limits during high-volume periods
  • Transaction Integrity: Complex flow with multiple API calls - ensure proper rollback mechanisms

HIGH - Address Soon After Go-Live

  • User Training: Multi-step process requires comprehensive user training for customer service teams
  • Error Handling: Limited error recovery options once cancellation APIs are called
  • Performance: Complex screen flows may be slow with large numbers of order items

MEDIUM - Future Enhancement

  • Bulk Operations: Currently handles one order at a time - consider bulk cancellation capabilities
  • Approval Process: No built-in approval workflow for high-value cancellations
  • Audit Trail: Enhanced logging of cancellation decisions and fees applied

LOW - Monitor

  • Fee Product Management: Automatic creation of fee products may require cleanup over time
  • Screen Flow UX: Multi-stage process could benefit from progress indicators
  • Order Status Sync: Monitor synchronization between OrderSummary and Order status updates

Maintenance Notes

Complexity: High - Multi-stage screen flow with OMS API integrations, fee management, and complex business logic. Requires deep understanding of Salesforce Order Management System. Review monthly for API usage patterns and quarterly for business rule accuracy. Thoroughly test any changes in sandbox with representative order data before deployment.