Definition
An sObject (Salesforce Object) is the Apex representation of a Salesforce standard or custom object. In Apex code, sObject is the generic data type that can represent any record, and specific sObjects like Account, Contact, or MyCustomObject__c are strongly-typed subtypes. Developers use sObjects to create, read, update, and delete records programmatically.
Real-World Example
A developer writes Apex code to create a new Account: Account acc = new Account(Name = 'TechCorp', Industry = 'Technology'); insert acc; Here, "acc" is an sObject of type Account. The developer can also use the generic sObject type: sObject genericRecord = acc; This flexibility allows utility methods that work across any object type.
Why sObject Matters
An sObject (Salesforce Object) is the Apex programming language's representation of a Salesforce record, serving as the base data type for all standard and custom objects. Every Account, Contact, Opportunity, or custom object record is an sObject when accessed in code. Developers can use the generic sObject type to write flexible utility methods that operate on any object type, or use specific sObject types like Account or Contact for compile-time field validation. This dual typing system solves the problem of writing reusable code while maintaining type safety where needed, giving developers both flexibility and guardrails.
As Salesforce orgs accumulate more custom objects and developers build more sophisticated automation, understanding sObjects becomes fundamental to writing efficient, maintainable Apex code. The generic sObject type enables patterns like dynamic field access using get() and put() methods, which are essential for building configurable tools that work across multiple objects without hardcoding field names. Without proper sObject understanding, developers write rigid, object-specific code that must be duplicated for each new object. Mastering sObjects also means understanding their relationship to describe calls, which provide runtime metadata about fields, record types, and picklist values needed for truly dynamic Apex solutions.
How Organizations Use sObject
- TechCorp Innovations — TechCorp Innovations builds a generic audit logging utility that accepts any sObject type. When a record is updated, the utility compares old and new field values using sObject.get() methods and logs changes to a custom Audit_Log__c object. The same code works for Accounts, Contacts, and all 30 of their custom objects without modification.
- DataSync Solutions — DataSync Solutions creates a data migration framework that uses the generic sObject type to process CSV imports for any object. The framework reads column headers, maps them to fields using describe calls, creates sObject instances dynamically, and inserts them in bulk. Adding support for a new object requires only a configuration record, not new code.
- Pinnacle Healthcare — Pinnacle Healthcare writes an Apex batch class that uses sObject generically to archive records older than seven years across 15 different objects. The batch job queries each object dynamically, creates archive records, and deletes originals in bulk, using a single reusable class instead of 15 separate batch implementations.