Skip to content

Flow Name: Delete Buyer Group Members Async

Last Updated: 2025-08-11 Source Code: Delete_Buyer_Group_Members_Async.flow-meta.xml

API Name: Delete_Buyer_Group_Members_Async Status: Active Type: Custom Trigger: Record-Triggered Flow (After Save) on BuyerGroupMember updates

Business Purpose

This flow provides a safe, asynchronous mechanism for removing member assignments from buyer groups. When a BuyerGroupMember record is flagged for deletion via the Delete_Member_Assignment__c checkbox, the flow automatically removes the assignment after the transaction completes, ensuring data integrity while preventing blocking operations during the main transaction processing.

Process Flow

  1. Trigger: Flow monitors all BuyerGroupMember record updates
  2. Evaluation: Checks if Delete_Member_Assignment__c field has been set to true
  3. Asynchronous Processing: If triggered, flow waits for the main transaction to commit successfully
  4. Deletion: After transaction commits, the BuyerGroupMember record is permanently deleted
  5. Error Handling: If deletion fails, a custom error message is generated with fault details

Key Design Decision: The flow uses AsyncAfterCommit processing, which means: - The deletion happens after the original transaction completes successfully - This prevents blocking the main process that flags records for deletion - Ensures referential integrity by waiting for all related updates to commit first - Allows for bulk processing without hitting governor limits

📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: BuyerGroupMember Updated]) --> Check{Delete_Member_Assignment__c<br/>= true?}
    Check -->|No| End1([End: No Action])
    Check -->|Yes| Wait[Wait for Transaction Commit<br/>AsyncAfterCommit]
    Wait --> Delete[Delete BuyerGroupMember Record]
    Delete -->|Success| End2([End: Record Deleted])
    Delete -->|Error| Error[Display Custom Error:<br/>Deletion Failed]
    Error --> End3([End: Error Logged])

    style Start fill:#e1f5ff
    style Check fill:#fff4e1
    style Wait fill:#e1ffe1
    style Delete fill:#ffe1e1
    style Error fill:#ff9999
    style End1 fill:#e1f5ff
    style End2 fill:#e1f5ff
    style End3 fill:#ff9999

Key Business Rules

Trigger Conditions

  • Object: BuyerGroupMember
  • When: After record is saved (After Save trigger)
  • Criteria: Delete_Member_Assignment__c field equals true
  • Record Change Required: Yes - field must change to true (not just already be true)

Processing Logic

  • Async Processing: Uses AsyncAfterCommit to ensure deletion occurs after the parent transaction completes
  • Single Record: Flow processes one BuyerGroupMember record at a time (uses $Record reference)
  • Permanent Deletion: Record is permanently deleted (hard delete, not moved to Recycle Bin)

Error Handling

  • Fault Connector: Any deletion errors are caught and routed to custom error handler
  • Error Message: Displays clear message indicating deletion failure with technical fault details
  • Error Format:
    An error occurred while deleting the Buyer Group Member assignment:
    -------------------------------------------------------
    [System fault message details]
    

Dependencies

Salesforce Objects

  • BuyerGroupMember: Standard Salesforce object for buyer group assignments
  • Delete_Member_Assignment__c: Custom boolean field that triggers deletion
  • This field must exist and be accessible to the flow
  • Buyer Group Management: This flow is part of the buyer group member lifecycle management
  • Membership Cleanup: Likely called when memberships expire, are revoked, or accounts are deactivated
  • Upstream Processes: Another flow or process must set Delete_Member_Assignment__c = true to trigger this flow

Permissions

  • Flow User: Must have Delete permission on BuyerGroupMember object
  • Field Access: Must have Edit access to Delete_Member_Assignment__c field
  • Record Access: Respects sharing rules - can only delete records the running user has access to

Changes

PR-41520 - Merged in feature/PR-41520-STAGING (pull request #1543) - Initial implementation of asynchronous buyer group member deletion - Introduced to prevent blocking operations during membership updates - Date: 2025-08-11

⚠️ Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • Custom Field Existence: Verify BuyerGroupMember.Delete_Member_Assignment__c field exists in target org before deployment
  • Permission Validation: Confirm all users who can update buyer group members have Delete permission on BuyerGroupMember object
  • Cascading Deletes: Verify that deleting BuyerGroupMember records doesn't break related business processes (orders, entitlements, product access)
  • Sharing Rule Impact: Ensure sharing rules don't prevent deletion - flow runs in system context but errors may occur if called from user context

HIGH - Address Soon After Go-Live

  • Async Processing Delay: Users won't see immediate deletion - there will be a delay between flagging and actual deletion (typically seconds, but could be minutes under load)
  • Error Visibility: Failed deletions only log errors - no user notification mechanism exists beyond the error message
  • Audit Trail: Consider if deleted BuyerGroupMember records should be archived before deletion for compliance/audit purposes
  • Bulk Operations: If bulk processes flag many records for deletion simultaneously, monitor async job queue for backlog

MEDIUM - Future Enhancement

  • Soft Delete Option: Consider implementing a soft delete (inactive flag) instead of hard delete for better audit trail
  • Notification System: Add email/chatter notification when deletions fail so admins are aware of issues
  • Batch Processing: If high volumes are expected, consider consolidating into a scheduled batch job instead of individual async deletions
  • Validation Before Delete: Add validation to check if record can safely be deleted (no active orders, entitlements, etc.)

LOW - Monitor

  • Async Queue Performance: Monitor Platform Events and Async Jobs to ensure deletions process quickly
  • Error Frequency: Track how often deletion errors occur - frequent errors may indicate permission or data issues
  • False Triggers: Monitor if records are accidentally flagged for deletion (need to add confirmation step?)
  • Governor Limits: Though unlikely with single-record processing, monitor for any limit issues in high-volume scenarios

Maintenance Notes

Complexity: Low Recommended Review Schedule: Annually or when buyer group functionality changes

Key Maintenance Considerations:

  1. Simple Design: This is a straightforward flow with minimal complexity - easy to understand and maintain
  2. Single Purpose: Flow does exactly one thing (delete) which reduces maintenance burden
  3. Good Error Handling: Custom error handler provides clear diagnostic information for troubleshooting
  4. Async Pattern: Using AsyncAfterCommit is best practice for deletion operations - prevents blocking main transactions

Areas that need careful testing when modified: - Changes to BuyerGroupMember object structure or relationships - Modifications to Delete_Member_Assignment__c field (name change, type change, etc.) - Updates to sharing rules or permission sets affecting BuyerGroupMember access - Integration with any upstream processes that set the deletion flag

Common Scenarios to Test: - Single record deletion (happy path) - Bulk record deletion (multiple records flagged simultaneously) - Deletion failure due to permission issues - Deletion failure due to locked records - Cascade impact on related objects (buyer groups, orders, entitlements)

Troubleshooting Tips: - If records aren't being deleted: Check if Delete_Member_Assignment__c field exists and is accessible - If errors occur: Review async job logs for detailed fault messages - If delays are long: Check Platform Event queue and async job queue for backlog - If permissions errors: Verify flow user/profile has Delete access to BuyerGroupMember

Related Flows: - Look for flows that set Delete_Member_Assignment__c = true to understand full deletion workflow - Check for flows that handle buyer group membership creation/updates - Review any flows that depend on BuyerGroupMember existence