Salesforce Tutorial: Learn CRM from Scratch (2026)
Salesforce is the world's leading CRM, used by companies of all sizes to manage sales, service, marketing, and more. After architecting Salesforce implementations for a global logistics company and a fintech startup, I have learned that the platform's power comes from its declarative-first approach — you can build sophisticated workflows without writing code — but the real magic happens when you extend it with Apex, LWC, and integrations.
This tutorial covers the Salesforce data model, declarative automation, Apex programming, Lightning Web Components, and integration patterns. No prior Salesforce experience needed.
Data Model: Objects and Relationships
Salesforce's data model is based on sObjects (standard objects like Account, Contact, Opportunity, Case) and custom objects. Each object has standard fields and custom fields (__c suffix). Relationships include lookup (optional) and master-detail (required, cascade delete). The sharing model controls record-level access.
Custom objects are created through Setup > Object Manager > Create > Custom Object. Schema Builder provides a visual drag-and-drop interface to design relationships. Always plan your data model before building — bad schema design is the most expensive mistake in a Salesforce project.
SELECT Id, Name, Type, BillingCity, (SELECT Id, Name, Amount FROM Opportunities)
FROM Account
WHERE CreatedDate = THIS_YEAR
ORDER BY Name
LIMIT 100
Declarative Automation
Salesforce lets you automate business logic without code. Validation rules prevent bad data. Workflow rules send email alerts (being phased out in favor of Flow). Flows are the modern declarative automation tool: screen flows guide users through processes, and autolaunched flows run in the background.
Flow is incredibly powerful — it can create records, send emails, make HTTP callouts, and implement complex branching logic. Always use Flow over Workflow Rules or Process Builder for new automation.
AND(
ISPICKVAL(StageName, 'Closed Won'),
CloseDate < TODAY()
)
IF(
ISBLANK(LastActivityDate),
0,
TODAY() - LastActivityDate
)
Apex Programming
Apex is a strongly typed, object-oriented language that looks like Java and runs on the Salesforce platform. Apex runs in a multi-tenant environment with strict governor limits: 100 SOQL queries per transaction, 10,000 records total, 3 MB heap size.
Triggers are the most common Apex entry point. Always bulkify triggers — they must handle collections rather than single records. Use Trigger.old for the previous state of records being updated.
trigger UpdateAccountRating on Opportunity (after update) {
Set accountIds = new Set();
for (Opportunity opp : Trigger.new) {
if (opp.Amount > 1000000 && opp.Amount != Trigger.oldMap.get(opp.Id).Amount) {
accountIds.add(opp.AccountId);
}
}
if (!accountIds.isEmpty()) {
List accounts = [SELECT Id, Rating FROM Account WHERE Id IN :accountIds];
for (Account acc : accounts) {
acc.Rating = 'Hot';
}
update accounts;
}
}
Lightning Web Components
LWC is Salesforce's modern UI framework built on web standards. Components are JavaScript classes with an HTML template and optional CSS. LWC replaces the older Aura framework and offers better performance, smaller bundle sizes, and compatibility with standard web development tools.
Components communicate via @api decorated properties, wire adapters, and custom events. For complex state management, use Lightning Data Service (@wire with getRecord) instead of imperative Apex calls.
import { LightningElement, api, wire } from 'lwc';
import getAccountData from '@salesforce/apex/AccountController.getAccountData';
export default class AccountSummary extends LightningElement {
@api recordId;
@wire(getAccountData, { accountId: '$recordId' })
account;
get annualRevenue() {
return this.account.data?.AnnualRevenue;
}
handleRefresh() {
refreshApex(this.account);
}
}
REST APIs and Integration
Salesforce integrates with external systems through REST/SOAP APIs, outbound messages, platform events, and external objects. The REST API supports CRUD on any sObject, query execution, and bulk operations. OAuth 2.0 with JWT Bearer Token is the recommended authentication for system-to-system integrations.
External objects map Salesforce queries to external data sources without copying data into Salesforce. For real-time integration, use Platform Events with CometD streaming.
@RestResource(urlMapping='/orders/*')
global with sharing class OrderAPI {
@HttpGet
global static Order__c getOrder() {
RestRequest req = RestContext.request;
String orderId = req.requestURI.substringAfter('/orders/');
return [SELECT Id, Name, Status__c, Total__c FROM Order__c WHERE Id = :orderId];
}
@HttpPost
global static Id createOrder(String customerName, Decimal total) {
Order__c order = new Order__c(
Customer_Name__c = customerName,
Total__c = total,
Status__c = 'New'
);
insert order;
return order.Id;
}
}
Testing and Deployment with SFDX
Salesforce DX (SFDX) brings modern DevOps to the platform. Use scratch orgs for development, sandboxes for testing, and unlocked packages for production deployments. Unit tests (@IsTest) are mandatory for any Apex that goes to production (minimum 75% code coverage).
CI/CD pipelines run Apex tests, scan code with PMD, and deploy via sfdx force:source:deploy.
@IsTest
class OrderAPITest {
@IsTest
static void testCreateOrder() {
Test.startTest();
RestRequest req = new RestRequest();
req.requestUri = '/services/apexrest/orders/';
req.httpMethod = 'POST';
RestContext.request = req;
Id orderId = OrderAPI.createOrder('Test Customer', 1500.00);
Test.stopTest();
Order__c order = [SELECT Name, Status__c FROM Order__c WHERE Id = :orderId];
System.assertEquals('New', order.Status__c);
}
}
Frequently Asked Questions
Do I need to know programming to use Salesforce?
No. Salesforce is designed for declarative (no-code) development. Admins can build complex automations with Flow, reports with Report Builder, and apps with Lightning App Builder. Apex and LWC are needed only for requirements that exceed declarative capabilities.
What is the difference between a Sandbox and a Scratch Org?
A Sandbox is a copy of your production org for testing. A Scratch Org is a temporary, source-driven environment created via SFDX for development and CI — it starts empty and is configured by your project's source files.
How do I handle Salesforce governor limits?
Governor limits exist because Salesforce runs multi-tenant. Best practices: batchify large DML operations, use collections not individual records in triggers, query only the fields you need, and implement pagination in SOQL.
Can I migrate data from another CRM to Salesforce?
Yes. Use Data Import Wizard (up to 50K records) or Data Loader (unlimited) for CSV-based migration. For complex migrations, use MuleSoft or Boomi. Always run data quality checks before migration.
Originally published on Ayodhyyya. Last updated June 1, 2026.