In this blog post, I will be presenting some common Salesforce Interview questions asked by employers in the past couple of years. I have also tried to cover some real-time questions as well.
Below is the list of common Salesforce interview questions:
Question 1: A custom object contains some records, now my requirement is to create field in this object with master detail relationship. Can we create master detail relationship in this case?
You can not create a Master detail relationship on a object if it already has records in it. You need to follow below steps to create a Master Detail Relationship:
Step 1: Create a Lookup relationship first.
step 2: Populate the value for the parent object in all the records.
Step 3: Change the field type from Lookup relationship to Master detail.
Question 2: What is difference between Role and Profile?
Profile controls the visibility of the application. It controls what object and fields are visible to the user but profile doesn’t control what records are visible to the user. Role controls the record level access whereas Profile define the object level access.You can not create a user without assigning a profile to the user but you can create a user without assigning a role.
Question 3: What are sandboxes and different types of sandbox?
Sandboxes contain the copy of your production data. You cannot directly make changes to the production environment. In order to make any changes, you need to first test the changes on the sandboxe like a developer sandbox or a QA sandbox and then if everything looks good, you can deploy those changes to production. Sandbox is the environment used for testing and developing application.
Types of Sandboxes:
1. Developer sandbox
2. Developer Pro sandbox
3. Partial copy sandbox
4. Full sandbox
Question 4: How can you get more than 50,000 records in trigger?
If I have more than 50000 items(custom object) in salesforce.And If I want to retrieve 50000 records using the below query :
List<Item__c> itm_list = [Select id, item_name__c from Item__c];
This query will result in governor limit exception, because the maximum number of records that can be fetched by a SOQL query is 50000. So in order to resolve this issue, you can use batch apex in which you can process the records in form of batches and each batch can have records under the governor limit standards. For e.g. if you have 1000 records to process, in that case you can divide these records in 5 batches and each batch will have 200 records. Similarly you can divide 50000+ records in the form of batches and process the each batch separately. Default batch size is 200 records.
Question 5: Can we call @future method in Batch apex?
@Future method can not be called from a batch class but a webservice can call the @Future method. So from your batch class, you can call an Apex webservice and that webservice can than call the @future method. So this is the work around to call the @future method from a Batch Apex.
Question 6: What is the difference between actionFunction , actionSupport, actionRegion?
<apex:actionSupport/> Invoke the controller method using AJAX when event occurs on page like onMouseOver, onClick, etc. and we can use action support for particular single apex component.
<apex:actionRegion>An area of a Visualforce page that demarcates which components should be processed by the Force.com server when an AJAX request is made. Only the components in the body of the <apex:actionRegion> are processed by the server, thereby increasing the performance of the page.
Question 7: What is stateless and stateful in Batch apex?
Batch Apex is stateless by default. That means for each execution of your execute method, you receive a fresh copy of your object. All fields of the class are initialized, static and instance.
If your batch process needs information which needs to be shared across transactions, one approach is to make the Batch Apex class stateful by implementing the Stateful interface. By making the batch apex stateful, it instructs Force.com to preserve the values of your static and instance variables between transactions.
Question 1: Can two users have the same profile? Can two profiles be assigned to the same user?
Question 2: What are Governor Limits in Salesforce?
Question 3: What is a sandbox org? What are the different types of sandboxes in Salesforce?
Question 4: Can you edit an apex trigger/ apex class in production environment? Can you edit a Visualforce page in production environment?
Question 5:What are the different data types that a standard field record name can have?
Question 6: What is the use of writing sharing rules? Can you use sharing rules to restrict data access?
Question 7:What are the different types of email templates that can be created in Salesforce?
Question 8:What are dynamic dashboards? Can dynamic dashboards be scheduled?
Question 9:What are the different types of reports available in Salesforce? Can we mass delete reports in Salesforce?
Question 10:What are the different types of object relations in salesforce? How can you create them?
Question 11:What happens to detail record when a master record is deleted? What happens to child record when a parent record is deleted?
Question 12: Can you have a roll up summary field in case of Master-Detail relationship?
Question 13: Explain the term “Data Skew” in Salesforce.
Question 14:How to handle comma within a field while uploading using Data Loader?
Question 15: For which criteria in workflow “time dependent workflow action” cannot be created?
Question 16: How many active assignment rules can you have in a lead/ case?
Question 17: What is the difference between a Role and Profile in Salesforce?
Question 18: Why do we need to write test classes? How to identify if a class is a test class?
Question 19:What is minimum test coverage required for trigger to deploy?
Question 20: What are the different ways of deployment in Salesforce?
Question 21: What is an external ID in Salesforce? Which all field data types can be used as external IDs?
Question 22: How many callouts to external service can be made in a single Apex transaction?
Question 23: How can you expose an Apex class as a REST WebService in Salesforce?
Question 24: What is the difference between a standard controller and a custom controller?
Question 25: How can we implement pagination in Visualforce?
Question 27: How to get the UserID of all the currently logged in users using Apex code?
Question 28: How many records can a select query return? How many records can a SOSL query return?
Question 29: What are the different types of collections in Apex? What are maps in Apex?
Question 30: How can you embed a Visualflow in a Visualforce page?
Question 31: What is the use of “@future” annotation?
Question 32: What are the different methods of batch Apex class?
Question 33: What is a Visualforce component?
Question 34: What is Trigger.new?
Question 35: What all data types can a set store?
Question 36: What is an sObject type?
Question 37: What is the difference between SOQL and SOSL?
Question 38: What is an Apex transaction?
Question 39: What is the difference between public and global class in Apex?
Question 40: What are getter methods and setter methods?
If you have a question(s) in mind which you came across in your interview. Please share with us in the comment section and I will add the question(s) to this list.