I am very new to the Apex programming first.And I know about Standard & Custom objects. And also the the custom objects have an extension of '__c'. I observed in the programming lot of reference about the sObject but i am not getting the concept of it clearly.
As per definitions I understood it as:
sObject is a generic abstract type that corresponds to any persisted object type. The generic sObject can be cast into a specific sObject type, such as an account or the Invoice_Statement__c custom object (Standard or Custom object type).
Can someone please help me to understand more about sObject.
– When, where & How it need to be used?
If possible a scenario or example to explain this will be helpful.
Best Answer
An
SObject
represents a specific table in the database that you can discretely query. The API Name is what you reference as ending in__c
. Standard SObjects have names likeAccount
orOpportunity
, whereas Custom SObjects and Custom Settings have names likeMyObject__c
orMySetting__c
. Custom Settings are special objects you can get without a query.You can store any specific record in a generic
SObject
property. If you do so, you lose the ability to get/set most fields by name, but can get them generically.