Flow Name: Set Tag Account Key on Assignment¶
Last Updated: 2025-06-19 Source Code: Set_Tag_Account_Key_on_Assignment.flow-meta.xml
API Name: Set_Tag_Account_Key_on_Assignment Status: Active Type: Custom Trigger: Before Account_Engagement_Tag__c create/update
Business Purpose¶
Automatically generates a composite unique key combining Account ID and Engagement Tag ID to enforce uniqueness and prevent duplicate tag assignments to the same account. Essential for maintaining data integrity in engagement tracking.
Process Flow¶
- Triggers before Account_Engagement_Tag__c record is created or updated
- Builds composite key string: "{Account__c}-{Engagement_Tag__c}"
- Assigns value to Tag_Account_Key__c field
- Record saves with unique key populated
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: Account Engagement Tag<br/>Create/Update Before Save]) --> Assign[Assign Tag Account Key:<br/>Tag_Account_Key__c =<br/>Account ID + Engagement Tag ID]
Assign --> End([End])
style Start fill:#e1f5ff
style Assign fill:#e1ffe1
style End fill:#e1f5ff
Key Business Rules¶
- Composite key format: AccountId-EngagementTagId (e.g., "001xx000003D8A0-a0Bxx000000ABC0")
- Executes on both create and update to maintain key accuracy
- Key must be defined as unique external ID field to prevent duplicates
- Operates in Before Save context for optimal performance
Dependencies¶
- Objects: Account_Engagement_Tag__c (custom junction object)
- Fields:
- Account__c (lookup to Account)
- Engagement_Tag__c (lookup to Engagement_Tag__c)
- Tag_Account_Key__c (text/external ID field - should be unique)
- Field Configuration: Tag_Account_Key__c must be marked as External ID with Unique checkbox
Changes¶
No Pull Request references found in metadata.
⚠️ Pre-Go-Live Concerns¶
CRITICAL - Fix Before Go-Live¶
- Field Configuration Required: Tag_Account_Key__c must be configured as External ID with Unique checkbox in field settings
- No Null Check: Doesn't validate that Account__c and Engagement_Tag__c are populated before creating key
- No Error Handling: No fault path if field references are invalid
HIGH - Address Soon After Go-Live¶
- Validation Rule Needed: Add validation rule to ensure Account__c and Engagement_Tag__c are required
- Unique Constraint: Verify Tag_Account_Key__c has unique constraint at database level
- User Experience: If duplicate prevented by uniqueness, error message should be user-friendly
MEDIUM - Future Enhancement¶
- Case Sensitivity: Consider whether IDs are always same case or need UPPER() normalization
- Audit Trail: Enable field history tracking on Tag_Account_Key__c for troubleshooting
LOW - Monitor¶
- Duplicate Attempts: Monitor for duplicate key errors to identify user confusion or process issues
- Key Length: Verify combined key doesn't exceed field length limit (typically 18+1+18 = 37 characters)
Maintenance Notes¶
Complexity: Very Low - Simple string concatenation Review Schedule: Annual review sufficient unless object relationships change Critical Configuration: Relies on Tag_Account_Key__c being properly configured as unique external ID Performance: Before-save trigger with simple assignment - very efficient Best Practice: This is the correct approach for enforcing uniqueness on junction objects Field Verification: Confirm Tag_Account_Key__c field settings: - Type: Text (255) - External ID: Checked - Unique: Checked - Case Sensitive: Checked