Skip to content

Flow Name: Before Insert/Update Practice Site

Last Updated: 2024-10-31 Source Code: Before_Insert_Update_Practice_Site.flow-meta.xml

API Name: Before_Insert_Update_Practice_Site Status: Active Type: Custom Trigger: Before save (create and update) of PracticeSite__c records when Display_On_Np_Finder__c changes

Business Purpose

This flow enforces business rules for the NP Finder directory by limiting each person to a maximum of 3 practice sites that can be displayed publicly. It validates member eligibility and prevents non-members from appearing in the directory, ensuring data quality and compliance with membership requirements for public-facing provider searches.

Process Flow

  1. Person Account Lookup: Retrieves the associated Person Account for the Practice Site
  2. Membership Validation: Checks if the person is an active member with valid membership status
  3. Directory Display Rules:
  4. Active Members: Allows "Display on NP Finder" for current members with non-expired status
  5. Expired/Non-Members: Prevents directory display by throwing an error if attempting to set Display_On_Np_Finder__c = true
  6. Count Validation: For valid members, counts existing practice sites already displayed in finder
  7. Limit Enforcement: Prevents exceeding 3 practice sites per person in the directory
📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: PracticeSite Create/Update<br/>Before Save Trigger]) --> DisplayChanged{Display_On_Np_Finder__c<br/>Changed?}

    DisplayChanged -->|No| End([End])
    DisplayChanged -->|Yes| GetAccount[Get Person Account<br/>for Practice Site]

    GetAccount --> MemberCheck{Is Active Member?<br/>Is_Member__c = TRUE<br/>AND<br/>Status ≠ Expired}

    MemberCheck -->|No & Display=TRUE| Error1[Throw Error:<br/>Only active members<br/>can display in finder]
    MemberCheck -->|Yes OR Display=FALSE| CountSites[Count Practice Sites<br/>Already Displayed<br/>excluding current]

    CountSites --> LimitCheck{Display=TRUE<br/>AND<br/>Count >= 3?}

    LimitCheck -->|Yes| Error2[Throw Error:<br/>Maximum 3 sites<br/>per person]
    LimitCheck -->|No| End

    Error1 --> Abort([Abort Save])
    Error2 --> Abort

    style Start fill:#e1f5ff
    style DisplayChanged fill:#fff4e1
    style GetAccount fill:#f0e1ff
    style MemberCheck fill:#fff4e1
    style CountSites fill:#e1ffe1
    style LimitCheck fill:#fff4e1
    style Error1 fill:#ffcccc
    style Error2 fill:#ffcccc
    style End fill:#e1f5ff
    style Abort fill:#ffcccc

Key Business Rules

  • Maximum 3 practice sites per person can have Display_On_Np_Finder__c = true
  • Only active members (Is_Member__c = true AND Membership_status__c ≠ "Expired") can display sites in finder
  • Expired members or non-members cannot set Display_On_Np_Finder__c = true
  • Validation runs when creating new sites or changing the Display_On_Np_Finder__c field
  • Counts exclude the current record being processed to avoid false positives

Dependencies

  • PracticeSite__c custom object with Display_On_Np_Finder__c and Account__c fields
  • Account standard object with IsPersonAccount, Is_Member__c, and Membership_status__c fields
  • NP Finder public directory functionality
  • PR-30662 (referenced in description)

⚠️ Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • User Experience: Error messages stop the save process but don't provide guidance on how to resolve (which sites to uncheck)
  • Data Migration: Existing accounts with >3 sites displayed will cause errors on any future updates

HIGH - Address Soon After Go-Live

  • Bulk Operations: Flow could cause issues during bulk data loads or migrations of practice site data
  • Member Status Changes: If member expires, existing displayed sites remain visible until manually updated

MEDIUM - Future Enhancement

  • User Guidance: Error messages could specify which existing sites are currently displayed
  • Automated Cleanup: Could automatically uncheck oldest sites when limit exceeded instead of blocking save

LOW - Monitor

  • Counter Logic: Simple loop counting could be replaced with SOQL COUNT() for better performance
  • Edge Cases: Handling of concurrent updates by same user not addressed

Maintenance Notes

Complexity: Medium - Business logic validation with multiple decision points and custom error handling. Review quarterly to ensure membership status validation aligns with business rules. Monitor error rates and consider UX improvements if users frequently encounter validation errors. Test thoroughly with bulk data operations.