Master the concepts of Salesforce in just 45 days Click here to know more.
Premium Salesforce Weekend Batch Start From Tomorrow.
Unlike any other programming language like Java or C#, Apex is tightly integrated with the database.
Hence we do not have to create any database connection to access the records or insert new records.
Instead, in Apex, we have sObjects which represent a record in Salesforce.
An account record named as Burlington Textiles in apex will be referred using an sObject, like this:
Account acc = new Account(Name=’Disney’);
The API object name becomes the data type of the sObject variable in Apex.
Account = sObject datatype
acc = sObject variable
new = Keyword to create new sObject Instance
Account() = Constructor which creates an sObject instance
Name =‘Disney’ = Initializes the value of Name field in account sObject
Similarly if we want to create a contact record using Apex then we first need to create a sObject for it in Apex, like this:
Contact con = new Contact();
Now there are 2 ways to assign field values to the contact sObject:
Contact con = new Contact(firstName = ‘Shrey’,lastName = ‘Sharma’);
con.firstName = ‘Shrey’;
con.lastName = ‘Sharma’;
Similarly for Custom Objects:
Student__c st = new Student__c(Name = ‘Arnold’);
If we want to assign the field values for custom fields then also we have to write down their field API name, like:
Account acc = new Account(Name = ‘Disney’, NumberOfLocations__c = 56);
Student__c st = new Student__c(Name = ‘Arnold’, Email__c = ‘arnold @gmail.com’);
< < 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.