By Justin Scott Costner | VectorFormed LLC
Sales and marketing alignment is a persistent challenge in Revenue Operations, frequently resulting in lead leakage, delayed response times, and fragmented data visibility. When leads are passed between departments without systemic guardrails, they languish in improper statuses or remain assigned to inactive users.
This configuration resolves this operational gap by deploying a declarative Record-Triggered Flow to automate the routing of Lead records between Sales and Marketing. By dynamically updating Record Types, Ownership (Queues), and Lead Status based on specific triggering actions, this architecture ensures strict SLA accountability. Furthermore, swapping Record Types upon handoff guarantees that the user interface (Page Layouts and Sales Paths) is contextually optimized for the department currently working the lead, maximizing user adoption and data hygiene.
Before initiating the build in a Sandbox environment, ensure the following foundational metadata elements are configured.
Lead (Standard Object)RecordType (Standard System Object)Group (Standard System Object - utilized for Queues)New, Marketing, and Nurture.Marketing Qualify (Marketing_Qualify__c). Default value must be False.Marketing Queue and Marketing Qualified Queue.Sales and Marketing. Assign these to distinct Page Layouts optimized for each department's required data capture.Phase 1: Flow Initialization & Entry Criteria
Lead.1 OR 2)1: Status Equals Marketing2: Marketing_Qualify__c Equals TruePhase 2: The Decision Matrix
Determine Handoff Direction.Status Equals Marketing.Marketing_Qualify__c Equals True.Phase 3: Dynamic Metadata Retrieval (Get Records)Crucial architecture note: Never hardcode IDs. Query metadata dynamically to ensure seamless deployments across environments.
RecordType. Filter: SobjectType Equals Lead AND DeveloperName Equals Marketing. Store only the first record's ID.Group. Filter: Type Equals Queue AND DeveloperName Equals Marketing_Queue. Store only the first record's ID.RecordType. Filter: SobjectType Equals Lead AND DeveloperName Equals Sales. Store only the first record's ID.Group. Filter: Type Equals Queue AND DeveloperName Equals Marketing_Qualified_Queue. Store only the first record's ID.Phase 4: Variable Assignment & Record Update
varLeadToUpdate).varLeadToUpdate.RecordTypeId = [ID from Get Marketing Record Type]varLeadToUpdate.OwnerId = [ID from Get Marketing Queue]varLeadToUpdate.Status = NurturevarLeadToUpdate.RecordTypeId = [ID from Get Sales Record Type]varLeadToUpdate.OwnerId = [ID from Get Marketing Qualified Queue]varLeadToUpdate.Status = NewvarLeadToUpdate.Marketing_Qualify__c = False (Recommended Practice: Reset the trigger checkbox)varLeadToUpdate to the database.This configuration relies entirely on Flow declarative logic. However, the SOQL equivalents utilized by the Flow engine to dynamically fetch environment-agnostic IDs are critical for the architect to understand:
SQL
-- Logic for fetching Record Type IDs safely in Flow
SELECT Id FROM RecordType WHERE SobjectType = 'Lead' AND DeveloperName = 'Sales' LIMIT 1
SELECT Id FROM RecordType WHERE SobjectType = 'Lead' AND DeveloperName = 'Marketing' LIMIT 1
-- Logic for fetching Queue IDs safely in Flow
SELECT Id FROM Group WHERE Type = 'Queue' AND DeveloperName = 'Marketing_Queue' LIMIT 1
SELECT Id FROM Group WHERE Type = 'Queue' AND DeveloperName = 'Marketing_Qualified_Queue' LIMIT 1
Data Type Warning: The OwnerId field on the Lead object is a polymorphic lookup. It accepts either User.Id or Group.Id. Ensure your Get Records element filters strictly by Type = 'Queue' to prevent assigning the Lead to a Public Group, which will trigger a DML exception.
Execute the following protocols in a Sandbox environment before packaging for production deployment:
Status field to Marketing.Marketing (verifiable via the distinct page layout/sales path). The Owner changes to Marketing Queue. The Status automatically updates to Nurture.Marketing Queue.Marketing_Qualify__c checkbox and save.Sales. The Owner changes to Marketing Qualified Queue. The Status updates to New.Get Records elements querying by DeveloperName to ensure the flow survives Change Set or DevOps deployments.