Master the concepts of Salesforce in just 45 days Click here to know more.
Premium Salesforce Weekend Batch Start From Tomorrow.
Generally while programming we use a specific sObject type when we are sure of the instance of the sObject but whenever there comes a situation when we can get an instance of any sObject type, we use generic sObject.
Generic sObject datatype is used to declare the variables which can store any type of sObject instance.
sObject s1 = new Account(Name = ‘DIsney’);
sObject s2 = new Contact(lastName = ‘Sharma’);
sObject s3 = new Student__c(Name = ‘Arnold’);
sObject Variable —> Any sObject Datatype instance
Note: Every Salesforce record is represented as a sObject before it gets inserted into the database and also if you retrieve the records already present into the database they are stored in sObject variable.
Note: We can also cast the generic sObjects in specific sObjects like this:
Account acc = (Account) s1;
Contact con = (Contact) s1; //Will throw a Runtime Exception: datatype mismatch
Similar to the sObject, we can also set and access values from Generic sObject. However, the notation is a little different.
Examples of setting the values and accessing them:
sObject s = new Account();
s.put(‘Name’, ‘Cyntexa Labs’);
Object objValue = s.get(‘Name’);
< < Previous
Next > >
The batch is going to start shortly. Fill the form given below to Register yourself now.
Fill out the form and get consulted by our Salesforce experts.
Fill out the form to figure out to detemine the perfect Salesforce profile for yourself.
Fill the form below to get a demo of this course.
Fill out the form to get your Premium Salesforce Development Course
Online Salesforce Development Course is soon going to be launched. Please fill the form and we will notify you about the course.