Sales Cloud & Service Cloud Architecture
📖 Concept
Understanding Salesforce's core clouds is essential for any developer or architect. Most enterprise orgs use Sales Cloud, Service Cloud, or both.
Sales Cloud — Key Features:
- Lead Management — Lead capture, scoring, assignment, conversion
- Opportunity Management — Pipeline tracking, forecasting, stage progression
- Account & Contact Management — 360° customer view
- Products & Price Books — Catalog, pricing tiers, discounts
- Quotes & Orders — CPQ (Configure, Price, Quote)
- Forecasting — Revenue forecasting, collaborative, customizable
- Einstein AI — Lead scoring, opportunity insights, activity capture
Service Cloud — Key Features:
- Case Management — Multi-channel case creation, assignment, escalation
- Knowledge Base — Article management, search, versioning
- Omni-Channel — Route work to agents based on capacity and skill
- Service Console — Multi-tab workspace for productivity
- Entitlements & SLAs — Service level tracking, milestones
- Field Service — Scheduling, dispatch, mobile worker app
- Einstein Bots — AI-powered chat bots
Developer considerations for each cloud:
Sales Cloud development:
- Custom Lead scoring and assignment rules
- Complex CPQ automation (price calculation, approval workflows)
- Opportunity stage management triggers
- Revenue recognition automation
- Sales analytics dashboards
Service Cloud development:
- Custom case assignment algorithms
- SLA monitoring and escalation triggers
- Knowledge article management
- Omni-Channel customization
- Customer portal (Experience Cloud)
- Chat bot integration
Architecture patterns by cloud:
Sales: Lead → Account + Contact + Opportunity → Quote → Order
Service: Case → Escalation → Knowledge → Resolution → Survey
Combined: Account → Contacts → Opportunities + Cases + Activities
💻 Code Example
1// Sales Cloud & Service Cloud Development Patterns23// 1. Lead Conversion with custom logic4public class LeadConversionService {56 public static Database.LeadConvertResult convertLead(7 Id leadId, Id accountId, Boolean createOpportunity8 ) {9 Lead lead = [10 SELECT Id, FirstName, LastName, Company, Email, Status11 FROM Lead WHERE Id = :leadId12 ];1314 Database.LeadConvert lc = new Database.LeadConvert();15 lc.setLeadId(leadId);1617 if (accountId != null) {18 lc.setAccountId(accountId); // Merge into existing account19 }2021 if (!createOpportunity) {22 lc.setDoNotCreateOpportunity(true);23 }2425 lc.setConvertedStatus('Qualified');2627 Database.LeadConvertResult result = Database.convertLead(lc);2829 if (result.isSuccess()) {30 // Post-conversion logic31 Id newAccountId = result.getAccountId();32 Id newContactId = result.getContactId();33 Id newOppId = result.getOpportunityId();3435 System.debug('Converted: Account=' + newAccountId +36 ', Contact=' + newContactId + ', Opp=' + newOppId);37 }3839 return result;40 }41}4243// 2. Case Auto-Assignment and Escalation44public class CaseAutomationService {4546 // Auto-assign cases based on criteria47 public static void assignCases(List<Case> cases) {48 // Load assignment rules49 Map<String, Id> queuesBySkill = new Map<String, Id>();50 for (Group q : [SELECT Id, Name FROM Group WHERE Type = 'Queue'51 AND Name LIKE 'Support_%']) {52 queuesBySkill.put(q.Name, q.Id);53 }5455 for (Case c : cases) {56 String priority = c.Priority;57 String product = c.Product__c;5859 // Route to appropriate queue60 if (priority == 'Critical') {61 c.OwnerId = queuesBySkill.get('Support_Tier3');62 } else if (product == 'Enterprise') {63 c.OwnerId = queuesBySkill.get('Support_Enterprise');64 } else {65 c.OwnerId = queuesBySkill.get('Support_General');66 }67 }68 }6970 // SLA monitoring71 public static void checkSLABreaches() {72 List<Case> breachedCases = [73 SELECT Id, CaseNumber, Priority, OwnerId, CreatedDate74 FROM Case75 WHERE Status != 'Closed'76 AND Priority = 'High'77 AND CreatedDate < :Datetime.now().addHours(-4)78 AND Escalated__c = false79 ];8081 for (Case c : breachedCases) {82 c.Escalated__c = true;83 c.Priority = 'Critical';84 }8586 if (!breachedCases.isEmpty()) {87 update breachedCases;88 }89 }90}9192// 3. Opportunity Forecasting93public class ForecastService {9495 @AuraEnabled(cacheable=true)96 public static Map<String, Decimal> getQuarterlyForecast(Id userId) {97 List<AggregateResult> pipeline = [98 SELECT StageName, SUM(Amount) totalAmount,99 SUM(ExpectedRevenue) weightedAmount100 FROM Opportunity101 WHERE OwnerId = :userId102 AND CloseDate = THIS_QUARTER103 AND IsClosed = false104 GROUP BY StageName105 ];106107 Decimal committed = 0;108 Decimal bestCase = 0;109 Decimal pipeline_total = 0;110111 for (AggregateResult ar : pipeline) {112 String stage = (String) ar.get('StageName');113 Decimal total = (Decimal) ar.get('totalAmount');114 Decimal weighted = (Decimal) ar.get('weightedAmount');115116 if (stage == 'Negotiation' || stage == 'Proposal') {117 committed += weighted;118 }119 bestCase += total;120 pipeline_total += weighted;121 }122123 // Add closed won124 Decimal closedWon = 0;125 AggregateResult[] won = [126 SELECT SUM(Amount) total FROM Opportunity127 WHERE OwnerId = :userId128 AND CloseDate = THIS_QUARTER129 AND StageName = 'Closed Won'130 ];131 if (won[0].get('total') != null) {132 closedWon = (Decimal) won[0].get('total');133 }134135 return new Map<String, Decimal>{136 'closedWon' => closedWon,137 'committed' => committed,138 'bestCase' => bestCase,139 'pipeline' => pipeline_total140 };141 }142}
🏋️ Practice Exercise
Salesforce Cloud Practice:
- Build a complete Lead-to-Opportunity conversion flow with custom field mapping
- Create a Case auto-assignment system using custom matching criteria
- Implement SLA monitoring with automatic escalation after 4 hours
- Build a sales forecasting dashboard showing pipeline by stage and quarter
- Create a Knowledge Base article management system with versions and approval
- Implement Omni-Channel routing for a support team with 3 skill groups
- Build a customer portal using Experience Cloud with case submission
- Create a CPQ flow that configures product bundles and calculates pricing
- Implement a Chatter-based case collaboration system
- Design a complete CRM architecture combining Sales and Service Cloud
⚠️ Common Mistakes
Not leveraging standard Sales/Service Cloud features before customizing — many requirements can be met with configuration (assignment rules, escalation rules, approval processes)
Ignoring Lead conversion mapping — custom fields on Lead must be mapped to Account, Contact, and Opportunity during conversion. Unmapped fields are lost
Over-architecting case routing — start with standard assignment rules and queues before building complex custom routing
Not considering Omni-Channel capacity — routing work to agents without checking their capacity leads to uneven workloads
Building custom forecasting when standard Forecasting works — Salesforce's built-in forecasting handles most use cases with configuration
💼 Interview Questions
🎤 Mock Interview
Mock interview is powered by AI for Sales Cloud & Service Cloud Architecture. Login to unlock this feature.