Sales Cloud & Service Cloud Architecture

0/2 in this phase0/41 across the roadmap

📖 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

codeTap to expand ⛶
1// Sales Cloud & Service Cloud Development Patterns
2
3// 1. Lead Conversion with custom logic
4public class LeadConversionService {
5
6 public static Database.LeadConvertResult convertLead(
7 Id leadId, Id accountId, Boolean createOpportunity
8 ) {
9 Lead lead = [
10 SELECT Id, FirstName, LastName, Company, Email, Status
11 FROM Lead WHERE Id = :leadId
12 ];
13
14 Database.LeadConvert lc = new Database.LeadConvert();
15 lc.setLeadId(leadId);
16
17 if (accountId != null) {
18 lc.setAccountId(accountId); // Merge into existing account
19 }
20
21 if (!createOpportunity) {
22 lc.setDoNotCreateOpportunity(true);
23 }
24
25 lc.setConvertedStatus('Qualified');
26
27 Database.LeadConvertResult result = Database.convertLead(lc);
28
29 if (result.isSuccess()) {
30 // Post-conversion logic
31 Id newAccountId = result.getAccountId();
32 Id newContactId = result.getContactId();
33 Id newOppId = result.getOpportunityId();
34
35 System.debug('Converted: Account=' + newAccountId +
36 ', Contact=' + newContactId + ', Opp=' + newOppId);
37 }
38
39 return result;
40 }
41}
42
43// 2. Case Auto-Assignment and Escalation
44public class CaseAutomationService {
45
46 // Auto-assign cases based on criteria
47 public static void assignCases(List<Case> cases) {
48 // Load assignment rules
49 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 }
54
55 for (Case c : cases) {
56 String priority = c.Priority;
57 String product = c.Product__c;
58
59 // Route to appropriate queue
60 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 }
69
70 // SLA monitoring
71 public static void checkSLABreaches() {
72 List<Case> breachedCases = [
73 SELECT Id, CaseNumber, Priority, OwnerId, CreatedDate
74 FROM Case
75 WHERE Status != 'Closed'
76 AND Priority = 'High'
77 AND CreatedDate < :Datetime.now().addHours(-4)
78 AND Escalated__c = false
79 ];
80
81 for (Case c : breachedCases) {
82 c.Escalated__c = true;
83 c.Priority = 'Critical';
84 }
85
86 if (!breachedCases.isEmpty()) {
87 update breachedCases;
88 }
89 }
90}
91
92// 3. Opportunity Forecasting
93public class ForecastService {
94
95 @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) weightedAmount
100 FROM Opportunity
101 WHERE OwnerId = :userId
102 AND CloseDate = THIS_QUARTER
103 AND IsClosed = false
104 GROUP BY StageName
105 ];
106
107 Decimal committed = 0;
108 Decimal bestCase = 0;
109 Decimal pipeline_total = 0;
110
111 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');
115
116 if (stage == 'Negotiation' || stage == 'Proposal') {
117 committed += weighted;
118 }
119 bestCase += total;
120 pipeline_total += weighted;
121 }
122
123 // Add closed won
124 Decimal closedWon = 0;
125 AggregateResult[] won = [
126 SELECT SUM(Amount) total FROM Opportunity
127 WHERE OwnerId = :userId
128 AND CloseDate = THIS_QUARTER
129 AND StageName = 'Closed Won'
130 ];
131 if (won[0].get('total') != null) {
132 closedWon = (Decimal) won[0].get('total');
133 }
134
135 return new Map<String, Decimal>{
136 'closedWon' => closedWon,
137 'committed' => committed,
138 'bestCase' => bestCase,
139 'pipeline' => pipeline_total
140 };
141 }
142}

🏋️ Practice Exercise

Salesforce Cloud Practice:

  1. Build a complete Lead-to-Opportunity conversion flow with custom field mapping
  2. Create a Case auto-assignment system using custom matching criteria
  3. Implement SLA monitoring with automatic escalation after 4 hours
  4. Build a sales forecasting dashboard showing pipeline by stage and quarter
  5. Create a Knowledge Base article management system with versions and approval
  6. Implement Omni-Channel routing for a support team with 3 skill groups
  7. Build a customer portal using Experience Cloud with case submission
  8. Create a CPQ flow that configures product bundles and calculates pricing
  9. Implement a Chatter-based case collaboration system
  10. 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.