A Lightning Web Component (LWC) that enables loan officers to hand off opportunities to underwriters with action plan templates and task management.
- Pre-Handoff Task Checklist - Visual progress tracking with completion percentage
- Underwriter Selection - Choose from available underwriters in your org
- Action Plan Templates - Select from Standard, Expedited, or Complex review workflows
- Task Preview - See what tasks will be created before handoff
- Smart Validation - Warning indicators for incomplete or overdue tasks
- Automated Case Creation - Creates underwriting case with tasks
- Stage Automation - Updates opportunity stage to "Underwriting"
- Chatter Notifications - Notifies assigned underwriter
- Mortgage Lending - Hand off loan applications to underwriting teams
- Commercial Lending - Route business loan opportunities
- Insurance Underwriting - Transfer policy applications
- Any Opportunity Handoff - Adaptable to any business process requiring opportunity transfer
# Clone the repository
git clone https://github.com/jwemmlinger/sf-opportunity-handoff.git
cd sf-opportunity-handoff
# Authenticate to your org
sf org login web --alias myorg
# Deploy to your org
sf project deploy start --target-org myorg- Download the ZIP file from the Releases page
- Navigate to Setup → Deploy → Deploy in your Salesforce org
- Upload the ZIP file and deploy
sf package install --package 04t...- Navigate to Setup → Object Manager → Opportunity
- Go to Lightning Record Pages
- Select your Opportunity Record Page
- Add the component or create a Quick Action (see below)
- Navigate to Setup → Object Manager → Opportunity → Buttons, Links, and Actions
- Click New Action
- Action Type: Lightning Component
- Lightning Component: c:opportunityHandoff
- Label: Hand Off to Underwriter
- Icon: Choose an appropriate icon
- Save and add to Page Layout
For enhanced functionality, create these optional custom fields on Opportunity:
Underwriter__c(Lookup to User) - Stores assigned underwriterHandoff_Date__c(Date) - Records when handoff occurredAction_Plan_Template__c(Text) - Stores selected template name
Update the Apex controller to reference these fields:
// Line 311 in OpportunityHandoffController.cls
opp.Underwriter__c = underwriterId;
opp.Handoff_Date__c = Date.today();
opp.Action_Plan_Template__c = actionPlanTemplateId;Ensure your Opportunity has an "Underwriting" stage, or update line 310 in the controller:
opp.StageName = 'Your_Stage_Name_Here';Edit OpportunityHandoffController.cls (lines 158-209) to customize templates:
List<ActionPlanTask> customTasks = new List<ActionPlanTask>{
new ActionPlanTask('Your Task Name', 1, 'High'), // Due in 1 day
new ActionPlanTask('Another Task', 3, 'Normal') // Due in 3 days
};
templates.add(new ActionPlanTemplate(
'custom_template_id',
'Custom Template Name',
'Description of this workflow',
customTasks
));By default, the component shows all active users. To filter by profile or role, update line 102:
List<User> underwriters = [
SELECT Id, Name, Email
FROM User
WHERE IsActive = true
AND (Profile.Name LIKE '%Underwriter%'
OR UserRole.Name LIKE '%Underwriter%')
WITH SECURITY_ENFORCED
ORDER BY Name
LIMIT 200
];Modify the Chatter notification in sendHandoffNotification() method (line 418) or replace with email:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(new String[] { underwriter.Email });
mail.setSubject('New Underwriting Case Assigned');
mail.setPlainTextBody('You have been assigned case: ' + underwrightCase.CaseNumber);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });force-app/main/default/
├── lwc/
│ └── opportunityHandoff/
│ ├── opportunityHandoff.html # Component template
│ ├── opportunityHandoff.js # Component logic
│ ├── opportunityHandoff.css # Styling
│ ├── opportunityHandoff.js-meta.xml # Metadata config
│ └── __tests__/ # Jest tests
└── classes/
├── OpportunityHandoffController.cls # Apex controller
└── OpportunityHandoffController.cls-meta.xml
- User opens component from Opportunity quick action
- Component loads:
- List of underwriters (via
getUnderwriters()) - Action plan templates (via
getActionPlanTemplates()) - Existing opportunity tasks (via
getOpportunityTasks())
- List of underwriters (via
- User selects underwriter, action plan, and adds notes
- On submit,
handoffToUnderwriter():- Creates a Case assigned to the underwriter
- Creates tasks from the action plan template
- Updates Opportunity stage
- Posts Chatter notification
- Navigates user to the new Case
- All SOQL queries use
WITH SECURITY_ENFORCED - FLS (Field-Level Security) is checked using
Security.stripInaccessible() - Apex class is
with sharingto respect record access
sf apex run test --test-level RunLocalTests --output-dir ./test-results --result-format humannpm install
npm run test:unit- Ensure you have active users in your org
- Check the underwriter filter query (line 102 in controller)
- Verify users have necessary permissions
- Add the "Underwriting" stage to your Opportunity sales process
- Or customize the stage name in line 310 of the controller
- Verify the action plan template ID matches the method logic (lines 378-395)
- Check that users have permission to create Tasks on Cases
- Ensure you added the action to the Opportunity page layout
- Verify the component is set as
isExposedin the metadata - Check Lightning App Builder permissions
// Line 283 in OpportunityHandoffController.cls
Case underwrightCase = new Case(
Subject = 'Underwriting Review: ' + opp.Name,
Description = buildCaseDescription(opp, underwriter, notes),
Status = 'New',
Priority = 'Medium',
OwnerId = underwriterId,
AccountId = opp.AccountId,
Origin = 'Loan Officer Handoff',
Type = 'Underwriting Review', // Add custom fields
Loan_Amount__c = opp.Amount
);Edit handleSubmit() method in opportunityHandoff.js (line 221) to:
- Show confirmation modal
- Add validation logic
- Navigate to different record page
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Trailblazer Community: Tag your questions with
opportunity-handoff
- Initial release
- Core handoff functionality
- Three action plan templates
- Task management and progress tracking
- Chatter notifications
- Unlocked package distribution
- Email notifications option
- Custom object support (not just Opportunity)
- Bulk handoff capability
- Action plan template builder UI
- Analytics dashboard
- Mobile optimization
Built with ❤️ for the Salesforce community
Keywords: Salesforce, Lightning Web Component, LWC, Opportunity Management, Underwriting, Loan Origination, Action Plans, Task Management
