Flow Name: On Order Summary Fulfilled: Create Subscription and Membership Records¶
Last Updated: 2025-10-09 Source Code: On_Order_Summary_Fulfilled_Create_Subscription_and_Membership_Records.flow-meta.xml
API Name: On_Order_Summary_Fulfilled_Create_Subscription_and_Membership_Records Status: Active Type: Custom Trigger: Order Summary status changes to "Fulfilled"
Business Purpose¶
This flow automatically creates subscription and membership records when an order summary is fulfilled. It handles both standard subscription products and membership-specific processing, including PAC contributions, while maintaining proper date calculations for stacking multiple subscription terms and ensuring payment information is populated on orders.
Process Flow¶
- Initial Setup: Retrieves PAC contribution products (Monthly P-PAC-998, Quarterly P-PAC-997, Annual P-PAC-032) and grace period from custom metadata
- Order Validation: Gets Order Summary products and validates if order contains paid items with payment summaries
- Account User Lookup: Retrieves account user information for timezone conversion of fulfillment date
- Product Analysis Loop: Examines each product to identify membership subscriptions and flag orders containing membership products
- Subscription Start Date Logic:
- If existing membership subscription exists, continues from end date + 1
- If no existing subscription, uses fulfillment date
- Handles timezone conversion for accurate local fulfillment datetime
- Subscription Creation: For products marked IsSubscription=true (excluding PAC contributions during PAC orders), creates subscription records with calculated start/end dates, grace periods, and auto-renewal settings
- Membership Processing: For subscription products with Family="Membership" or specific Fellow SKUs (P-FELO-074, P-FELO-075, P-FELO-076), creates corresponding membership records
- Payment Updates: Updates original order with payment amount, date, balance, and payment method information
- Scheduled Path: Delayed 3-minute execution to update order payment information
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: Order Summary status changes to "Fulfilled"]) --> Lookup[Lookup Related Data]
Lookup --> Found{Data<br/>Found?}
Found -->|No| End([End])
Found -->|Yes| Calculate[Calculate/Determine Values]
Calculate --> Update[Update Records]
Update --> End
style Start fill:#e1f5ff
style Lookup fill:#f0e1ff
style Found fill:#fff4e1
style Calculate fill:#e1ffe1
style Update fill:#ffe1e1
style End fill:#e1f5ff
Key Business Rules¶
- Only processes orders with Status="Fulfilled"
- Excludes PAC contribution products from subscription creation when isPACOrder=true
- Membership subscriptions stack: new subscription starts day after existing membership ends
- Non-membership subscriptions use fulfillment date as start date
- Grace period dynamically retrieved from Environment_Settings__mdt (defaults to 30 days)
- Fellow products create both subscription and membership records
- Auto-renewal flag inherited from account setting
- Subscription quantities multiply the term length (stacking feature)
- Payment information copied from OrderPaymentSummary to Order record
Dependencies¶
- OrderSummary object with Status field
- Subscription__c custom object
- Membership__c custom object
- ChargentOrders__ChargentOrder__c object
- Environment_Settings__mdt for grace period configuration
- Product2.IsSubscription__c, Product2.Family, Product2.Product_Term__c fields
- Order.Manual_Order__c, Order.Fulfillment_Date__c fields
- LocalTimeConverter Apex class for timezone conversion
Changes¶
- PR-33058: Add stacking to multiply subscriptions purchased
- PR-27994,PR-28950: Changed logic to create subscription records for isSubscription products only
- PR-28950: Added logic to create membership records for Fellow products
- PR-31929: Added off-cycle community subscriptions end date match AANP membership end date
- PR-33499: Fix stacking attempt on non-membership products
- PR-32284: Update hardcoded grace period to dynamically retrieved from custom metadata
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- Missing error handling for failed subscription/membership record creation
- No validation if multiple active membership subscriptions exist for same account
- LocalTimeConverter Apex class dependency not validated - flow will fail if class doesn't exist
- Hardcoded Fellow product SKUs (P-FELO-074, P-FELO-075, P-FELO-076) should be configurable
HIGH - Address Soon After Go-Live¶
- Complex formula logic for subscription dates could cause incorrect calculations if product terms are null
- No bulk processing limits - large orders could hit governor limits
- Payment method lookup chain could fail silently leaving incomplete payment data
- Scheduled path runs regardless of whether main flow succeeded
MEDIUM - Future Enhancement¶
- Subscription stacking logic only considers latest membership subscription, not all overlapping subscriptions
- No audit trail for which flow execution created subscription/membership records
- PAC contribution identification relies on hardcoded SKUs instead of product family/type
- Grace period fallback to 30 days may not align with business requirements
LOW - Monitor¶
- Flow description contains outdated PR references and could be cleaned up
- Variable naming inconsistency (membershipSubscriptionStartDate vs subscriptionStartDate)
- Multiple similar record update elements could be consolidated
- Timezone conversion only applied to membership subscriptions, not all subscription types
Maintenance Notes¶
This flow has high complexity with multiple nested loops, decision trees, and formula calculations. The subscription date calculation logic is particularly complex and should be thoroughly tested when making changes. Recommend reviewing every 6 months due to frequent product SKU changes and business rule updates. Monitor for governor limit issues as order volumes increase.