Saturday 27 June 2020

Episode 1- Ten Most Frequently Asked Questions for Salesforce Developer Interview

If you are preparing  for  a Salesforce  interview and you want one stop blog where you can brush up your knowledge in very less time ,you are at the correct place.Here are the list of 10 most frequently asked questions for Salesforce Developer Interview.Before wasting time ,lets get started😊.
Please read the blog till the end to know the BONUS TIP.

Q.1 What is the difference between Process builder and Workflow Rule.

Process Builder is more advanced version of workflow rule as there are only 4 actions possible in workflow rule namely:

  • Update the Record.
  • Send an email alert.

  • Create a task.

  • Send an Outbound Message.
but in Process builder there are multiple more actions possible like:

  • Post to chatter.
  • Create the record.
  • Call flows(Autolaunced flows).
  • Submit for  approval.
  • Call apex code.

  • send email alerts.
  • Call another process builder.
  • Update related records.

Workflow Rule is equivalent to single if-then statements.

Process builder allows multiple If-then statements and can perform multiple actions on the basis of given criteria.


Process builder has an advantage over workflow rule as we can control the order of actions .

In Workflow Rule you cannot control your order of evaluation.


Q.2 What is the difference between Profile and Role.

Profile is the collection of permissions given to user to access objects,fields, tabs ,page layouts ,record types  in Salesforce.

Profile is mandatory to be assigned to user.


Role controls the visibility of data i.e record level of access, access to organization data.It is not mandatory to assign to the user.



Q.3 What is the view state error in Visual force.

View State holds the size of the Visual force Page which includes field values,components and controller.Salesforce allows maximum size of Visual page view state to be 170 KB.If the size of the page exceeds its value,the page will throw a View State Error.



Q.4 How Can we Reduce View State Error .

Some of the ways to reduce View State Error are:


  • Use Transient Keyword: Transient variables store the value temporary and thus does not store it in view state.

  • Filter Your SOQL Queries:The use of And and Where clause , removing null values can filter the records that is displayed on the page.Thus,only relevant data will be displayed on the Page.

  • Avoid using multiple forms on a Visual force Page.

  • Use Custom Settings Instead of Custom Objects as Custom settings store the data in the application cache so you don't have to use SOQL queries to retrieve data.


Q.5 Best Practices of Writing the trigger.

  • Avoid using DML and SOQL   statements inside the for loop.

  • Use One Trigger per Object: If you don't , then you cannot control the order of execution if those triggers run in same context.

  • Always Use Trigger Helper class and write all the logic in it so that it can be re-used later.

  • Bulkify your code: Always make sure your trigger can handle multiple records at a time.

  • Use @future Annotation Appropriately:Your Trigger should handle multiple records at a time and this is the critical aspect even when we use Asynchronous Apex methods(those annotated with @future)

  • Avoid Using Hard Coded Id's: When you deploy your code from sandbox to production there might be the situation your Record Ids gets changed between environment and your code fails.
  • Use Collections and Efficient For Loops:It is important to use Collections wisely to query and store the data efficiently.
  • Use Trigger Context Variables: Context variables are contained in System.Trigger class for example isInsert ,isUpdate , isBefore, isAfter etc.Use of these variables in Trigger can help in controlling the flow of the code.


Q.6 Basic Difference between SOQL and SOSL.


 SOQL                                                                                                                                                                         
 SOSL                                                                
 SOQL(Salesforce Object Query Language )    
use 'SELECT' keyword to retrieve the records from database.
SOSL (Salesforce Object Search Language)  use 'FIND' Keyword to retrieve retrieve the records from database.
 We can search any field in SOQL We can search only name,phone and email fields in SOSL
The Scenario where we  SOQL is used
when we know in which object the fields exist.

Scenario where SOSL is used when we don't know in which object the field exist
 We can retrieve data from single object or related multiple objects. We can retrieve data from objects and fields even if they are not related to each other.
 The return type of SOQL can be sObject ,List of sObjects or an integer to count. The return type of SOSL is always List<List<sObject>>

Q.7 What are the three different types of Object Relationship in Salesforce?


1. Lookup Relationship: Lookup Relationship is loosely Coupled parent-child relationship that links two objects in Salesforce. It is one to many relationship.Loosely Coupled here means the child is not bounded with its parent.It is not mandatory to have value in child lookup record.


2 .Master Detail Relationship: Master Detail Relationship is tightly coupled parent-child relationship i.e if you delete parent record,child records automatically gets deleted(cascading delete property).Moreover the child shares the security rules of its parent.

Roll-up Summary field can only be created in Master Detail Relationship.It is also one-many relationship.It is mandatory to have value in child lookup record.



3 .Many-Many Relationship: In Salesforce we can have many-many relationship using the junction object.It is created using two master-detail relationship with its parent object.



Q8 Can we convert master to lookup relationship?

Yes you can convert master to lookup relationship in Salesforce only if there is no roll-up summary field exist on the master object as there is no concept of roll up summary field in lookup relationship.


Q9 .Can we convert lookup to master detail relationship?

Yes you can convert lookup to master detail relationship only if lookup field in child records must contain the value.


Q10 Best Practices of Writing the Test Class.

  • Use System.Assert statements to verify your expected and Actual Result.

  • Use Test.startTest() and Test.stopTest() to reset governor limits

  • Besides having 75% mandatory criteria of passing Test Coverage, your test class should pass positive,negative ,bulk and single record criteria

  • Avoid using (seeAllData =true ) condition as there are chances your code may fail,Instead use your own Test data.

  • You can load CSV file as static resource in salesforce, which can act as a test data for your test classes.

  • You can also Create Test Factory classes with @isTest annotation which can act as test data.

  • Use @TestVisible annotation to access private members and methods inside the test class,

  • You can also use powerful @testSetup annotation in one of the method to create test records for the class.The records created in this method will be available to all the test methods of the class.

  • Use System.runAs () method to test the application in different user context. This aspect is critical from Security point of view.


BONUS TIP:Always add perspective to your answers For Example you can quote some examples from real time scenario or relevant story(related to the topic) from your project in your answers .This can add value to your answers.

Thanks for reading my blog and if is helpful to you ,do comment.You can also comment if you want me to write blog on  any  topic specific interview questions in Salesforce.







12 comments:

If you have any doubts ,Please let me know.

Episode 13 : RollUp Summary Trigger for Lookup Relationship

 As we all know we can use roll-up summary field logic only for the master-detail relationship, but in case you have the business requiremen...