Skip to content

Flow Name: Populate Business/Person Account Ids with unique Ids

Last Updated: 2025-08-19 Source Code: Populate_Business_Person_Account_Ids_with_unique_Ids.flow-meta.xml

API Name: Populate_Business_Person_Account_Ids_with_unique_Ids Status: Obsolete Type: Custom Trigger: Before Account create

Business Purpose

Assigns sequential unique identifiers to Person and Business Accounts upon creation, providing human-readable IDs for reporting and reference. Person Accounts start at 3000000, Business Accounts start at 6000000.

Process Flow

  1. Triggers before Account record creation
  2. Determines account type (Person vs Business)

  3. For Person Accounts:

  4. Queries for last created Person Account with PersonId__c populated
  5. Sorts by PersonId__c descending to get highest value
  6. If found: Increments last PersonId__c by 1
  7. If not found: Assigns "3000000" as first ID
  8. Stores in PersonId__c field

  9. For Business Accounts:

  10. Queries for last created Business Account with BusinessId__c populated
  11. Sorts by BusinessId__c descending to get highest value
  12. If found: Increments last BusinessId__c by 1
  13. If not found: Assigns "6000000" as first ID
  14. Stores in BusinessId__c field
📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: Before Create]) --> CheckType{Person or<br/>Business?}
    CheckType -->|Person| QueryPerson[Query Last PersonId]
    CheckType -->|Business| QueryBusiness[Query Last BusinessId]
    QueryPerson --> IncrementPerson[Increment PersonId<br/>or Start at 3000000]
    QueryBusiness --> IncrementBusiness[Increment BusinessId<br/>or Start at 6000000]
    IncrementPerson --> AssignPerson[Assign to PersonId__c]
    IncrementBusiness --> AssignBusiness[Assign to BusinessId__c]
    AssignPerson --> End([End])
    AssignBusiness --> End

    style Start fill:#e1f5ff
    style CheckType fill:#fff4e1
    style QueryPerson fill:#e1ffe1
    style QueryBusiness fill:#e1ffe1
    style IncrementPerson fill:#ffe1e1
    style IncrementBusiness fill:#ffe1e1
    style AssignPerson fill:#ffe1e1
    style AssignBusiness fill:#ffe1e1
    style End fill:#e1f5ff

Key Business Rules

  • Person Account starting ID: 3000000
  • Business Account starting ID: 6000000
  • IDs stored as text fields but incremented numerically
  • Sequential assignment (no gaps unless manually modified)
  • Only assigns on create (not update)
  • Queries sorted descending to get highest current value

Dependencies

  • Objects: Account (standard)
  • Fields: PersonId__c, BusinessId__c (text fields)
  • Account Types: Person Account vs Business Account (IsPersonAccount flag)

Changes

No Pull Request references found in metadata.

⚠️ Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • FLOW IS OBSOLETE: This flow is marked as Obsolete - should NOT be activated
  • Race Condition: Multiple simultaneous creates could assign same ID (not transaction-safe)
  • Performance: Query in before-save trigger could cause timeouts with large data volumes
  • Scalability: Text-based incrementing is not scalable for high-volume orgs

HIGH - Address Soon After Go-Live

  • Not Applicable: Flow is Obsolete

MEDIUM - Future Enhancement

  • Not Applicable: Flow is Obsolete

LOW - Monitor

  • Not Applicable: Flow is Obsolete

Maintenance Notes

Complexity: Medium - Queries, type conversion, conditional logic in before-save Status: OBSOLETE - Do not activate this flow Recommended Alternative: Use Auto-Number fields or External ID fields with proper sequencing Performance Issue: Before-save queries are problematic at scale Race Condition Risk: This approach cannot guarantee uniqueness under concurrent load Better Solution: Consider using Salesforce Auto-Number fields: - Format: P-{00000000} for Person Accounts starting at 3000000 - Format: B-{00000000} for Business Accounts starting at 6000000 Delete Recommendation: Remove this obsolete flow and implement Auto-Number fields instead