Skip to content

Flow Name: Alert on Order: Number of Individuals Changed

Last Updated: 2025-05-01 Source Code: Alert_on_Order_Number_of_Individuals_Changed.flow-meta.xml

API Name: Alert_on_Order_Number_of_Individuals_Changed Status: Active Type: Custom Trigger: After Order creation (Draft status, Manual Orders only)

Business Purpose

Sends email notifications to users with Membership permission set when the Number of Individuals field changes on an Account related to a manual Order. This flow ensures stakeholders are alerted to membership size changes that may impact pricing or service delivery.

Process Flow

  1. Initial Check: Triggered when Draft manual Orders are created
  2. Individual Count Validation: Checks if Individual_Count_Changed__c is true on the related Account
  3. User Lookup: Retrieves the current user's record for permission validation
  4. Permission Set Validation:
  5. Looks up "Membership" permission set
  6. Verifies current user has this permission set assigned
  7. Account Data Retrieval: Gets related Account information for email content
  8. Email Notification: Sends HTML email with account name and new individual count
  9. Cleanup: Resets the Individual_Count_Changed__c flag to false after notification
📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: Order Create After Save<br/>Draft Manual Orders]) --> CountCheck{Account<br/>Individual_Count_Changed__c<br/>= TRUE?}

    CountCheck -->|No| End([End])
    CountCheck -->|Yes| GetUser[Get Current User Record]

    GetUser --> GetPermSet[Get "Membership"<br/>Permission Set]

    GetPermSet --> CheckPerm{User Has<br/>Membership<br/>Permission Set?}

    CheckPerm -->|No| End
    CheckPerm -->|Yes| GetAccount[Get Account Details<br/>for Email Content]

    GetAccount --> SendEmail[Send HTML Email:<br/>Account Name and<br/>New Number of Individuals]

    SendEmail --> ResetFlag[Reset Account<br/>Individual_Count_Changed__c<br/>to FALSE]

    ResetFlag --> End

    style Start fill:#e1f5ff
    style CountCheck fill:#fff4e1
    style GetUser fill:#f0e1ff
    style GetPermSet fill:#f0e1ff
    style CheckPerm fill:#fff4e1
    style GetAccount fill:#f0e1ff
    style SendEmail fill:#ffe1e1
    style ResetFlag fill:#ffe1e1
    style End fill:#e1f5ff

Key Business Rules

  • Only processes Draft manual Orders (Status = 'Draft' AND Manual_Order__c = true)
  • Requires Account to have Individual_Count_Changed__c = true
  • Only sends notifications to users with "Membership" permission set
  • Email includes Account name and new Number of Individuals value
  • Automatically resets the change flag after processing

Dependencies

  • Account object with Individual_Count_Changed__c and Number_of_Individuals__c fields
  • Order object with Manual_Order__c field
  • PermissionSet named "Membership"
  • PermissionSetAssignment object for user permission validation
  • User email configuration

Changes

No specific PR notes found in metadata

⚠️ Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • Hardcoded Permission Set Name: Flow looks for exact "Membership" permission set name - if renamed, flow breaks completely
  • Missing Null Checks: No validation if Account lookup fails or User record is missing
  • Email Failure Handling: Error handling exists but doesn't retry or queue failed emails for later processing

HIGH - Address Soon After Go-Live

  • Performance Issue: Multiple sequential database lookups could cause timeouts on high-volume days
  • Email Dependency: Flow assumes user email exists and is valid - could fail silently
  • Trigger Scope: Only processes manual Draft orders, may miss other relevant scenarios

MEDIUM - Future Enhancement

  • Error Messaging: Custom error messages could be more descriptive for troubleshooting
  • Audit Trail: No logging of which notifications were sent successfully
  • Email Template: Uses inline HTML instead of reusable email template

LOW - Monitor

  • Label Inconsistency: Flow label mentions "Notify membership user" but interviewLabel is truncated
  • Variable Usage: Several unused variables declared (promotionIds, promotionWBTargetPriceId, etc.)

Maintenance Notes

Complexity: Medium - Multiple decision points and database lookups require careful testing. The hardcoded permission set dependency makes this flow brittle to organizational changes. Recommended quarterly review to ensure permission set name hasn't changed and email delivery is functioning properly.