Salesforce Interview Questions

Salesforce Interview Questions for admin and developer


**************************************************************************************************************

What is Salesforce?What is CRM?

Salesforce is the company which provides cloud-based software. As Salesforce is in the cloud, one can use it from anywhere with active internet connection. Salesforce is "Software as a service" as well as "platform as a service".

CRM stands for Customer Relationship Management is an application which is used to automate the process, using salesforce we can store all our important data on the cloud using standard and custom objects and can access it any time when we need.

Salesforce provides apps such as Sales, Marketing, Service as "software as service" whereas it provides a tool called "force.com" where you can customize your application using apex,visualforce.

**************************************************************************************************************

What is Profile/Role hierarchy/Permission set in salesforce?


The profile is a collection of permission which determines which task user can perform.
Profile controls permission such as objects access, field access, tab access, record type visibility etc. By default, salesforce provides some standard profiles such as system administrator, read-only, marketing user, standard user etc. We cannot delete these profiles. We can delete custom profiles if no user is assigned to it.

Role hierarchy basically deals with the user access to organization data. The user in the top-level hierarchy has automatic access to data of the user who is below in hierarchy. If we don't want these we can uncheck the grant access using hierarchy checkbox for custom objects. We cannot unchecked it for standard objects.

If we want to give some additional permission to the user we can give it through permission sets.


**************************************************************************************************************

Explain difference between SOQL for loop and List for loop?


SOQL List vs SOQL For Loop (Click on the link for complete details)

**************************************************************************************************************

What is junction object in salesforce?


**************************************************************************************************************

What is With sharing and Without sharing in salesforce?



**************************************************************************************************************

What is workflow and what is process builder?



workflow is an automation used to perform tasks such as,
1)Field update
2)Email alert
3)New task
4)Outbound message

Evaluation criterion in the workflow:
1)created
2)created and every time it is edited
3)created and any time it is edited to subsequently meet criteria

Process builder is an automation that lets you automate the process and see the graphical representation of what have you build.

Following are the actions that you can do using process builder,
1)Create record.
2)Update related record.
3)Send emails.
4)Post to chatter feed.
5)Submit record for approval.

Process builder is used when you have multiple if/else conditions that need to be checked which you cannot do in the workflow. Process builder can call your apex code but workflow cannot.

**************************************************************************************************************

Is 15 digit id case sensitive?what does first three digit represents?

Yes it is case sensitive, the first three digit represents object.

**************************************************************************************************************

What are governor limits in salesforce?


Governor limits in salesforce (Click on the link for complete details)

*************************************************************************************************************

Is it possible to uncheck grant access using hierarchy checkbox for a standard object?

No.

**************************************************************************************************************

What are objects relationship in salesforce?



Basically, we have three different types of object relationship in Salesforce

==>Lookup(One to Many)
==>Masterdetail(One to Many)
==>Junction object(Many to Many)

Lookup(One to Many):

In this type of relationship if we delete parent record child record will be still there.

Master-detail(One to Many):

In this type of relationship if we delete parent record child record will get deleted as well.

Junction object(Many to Many):

This type of relationship is required for creating many to many relationships between objects.
Here we require one more object to establish many to many relationships between other objects.
The third object will have two master-detail one for each object.

**************************************************************************************************************

What type of relationship is required for roll-up summary field?

Roll up summary field requires a master-detail relationship between objects.


**************************************************************************************************************

What is wrapper class in salesforce?

Wrapper class in salesforce (Click on the link for complete details)

**************************************************************************************************************

What is future methods in salesforce?

future method in salesforce (Click on the link for complete details)

**************************************************************************************************************

Is it possible to call future method from Batch class or another future method?


No, we cannot call.

*************************************************************************************************************

What operations you can perform using roll-up summary fields?

You can perform operations such as,
==>Counting related records.
==>Finding Minimum value in child records.
==>Finding Maximum value in child records.
==>Calculating sum.


**************************************************************************************************************

What are types of collections in salesforce? 

Collection in Salesforce (click on the link for complete details) 

**************************************************************************************************************

What is trigger in salesforce and what are trigger events in salesforce?


We basically use triggers to perform an operation such as validation(Preventing wrong data entry),updation(updating related records).

Following are the events on which trigger fires,


Before insert
Before update
Before delete
After insert
After update
After delete
After undelete

**************************************************************************************************************

What are trigger context variables in salesforce? Why we should use them?


Following are the Trigger context variable available,

trigger.isbefore()
=>Check if the trigger is in before mode, If the trigger is in before mode it will return true.

trigger.isafter()
=>Check if the trigger is in after mode, If the trigger is in after mode it will return true.


trigger.isupdate()
Check if the trigger is in update mode, If the trigger is in update mode it will return true.

trigger.isdelete()
Check if the trigger is in delete mode, If the trigger is in delete mode it will return true.


trigger.isinsert()
Check if the trigger is in insert mode, If the trigger is in insert mode it will return true.


trigger.isundelete()
Check if the trigger is in undelete mode, If the trigger is in undelete mode it will return true.


trigger.isexecuting()
Check if the apex class method is getting called from apex trigger, If getting called return true.


trigger.new()
Stores new records.

trigger.newmap()
Stores new records with id's

trigger.old()
Stores old records.

trigger.oldmap()
Stores old records with id's.

We should use the above context variable in the trigger and call helper class accordingly from trigger based on an event to avoid writing multiple triggers as the order of execution is not guaranteed in multiple triggers on the same object.

**************************************************************************************************************

What is the difference between Trigger.new and Trigger.old and Trigger.newmap and Trigger.oldmap ?

Trigger.new returns new records and Trigger.old return data before updates were done.

Trigger.newmap returns new records with id's and Trigger.oldmap return data before updates were done with id's.

**************************************************************************************************************

Is the id of record changes if we undelete a deleted record?

No, It has the same id.

**************************************************************************************************************

What is the use of trigger.isexecuting?

Suppose we have a method in apex class and we want this method to run only when the method is getting called from apex trigger than we can make use of trigger.isexecuting.

**************************************************************************************************************

What is test class in salesforce? 


Now, why we require a test class?

.When we are moving code from sandbox to production org we need to write a test class.
.Whatever code we have written we need to ensure that each and every condition is correct
and we can create a dummy data for it.
.The code must have 75% coverage to deploy it to production.

Points to remember.

.Test class does not have access to organization data but if we write @isTest(seeAllData=true),
then we can access data in the test class as well.
.As every organization have code limit by writing @isTest above test class, the limit will not be considered.
.Every test class has a method declared with testmethod keyword and is static.
Syntax: static testmethod void methodname()
{

}

**************************************************************************************************************

What is test.starttest() and test.stoptest()? 


.Whatever test we are performing we write the test inside of Test.starttest() and Test.stoptest.
.Basically they help to create a fresh set of governing limit.
.Each test method can call the start test and stop test only once.

**************************************************************************************************************

What is the use of seeAllData=true ? 


==>seeAllData=true


If we are defining a test class with @isTest(SeeAllData=true) then we can access data in test class from the database under all method present in the test class. Under this case annotating a method with @isTest(SeeAllData=false) would be ignored and you can access database data inside this method as well.
Let's understand with an example.

@isTest(SeeAllData=true)

public class testclassexample {

static testmethod void testMethodFirst() {


contact obj = [SELECT Id, Name from contact where name='test' LIMIT 1];
//Accessing contact from database


}

@isTest(SeeAllData=false)
static testmethod void testMethodFirst() {


contact obj1 = [SELECT Id, Name from contact where name='test' LIMIT 1];
//Accessing contact from database although @isTest(SeeAllData=false) is applied for method but it will get ignored
as test class is having @isTest(SeeAllData=true).


}

}

**************************************************************************************************************

What is the use of seeAllData=false ? 


==>@isTest(SeeAllData=false)

If we are defining a test class with @isTest(SeeAllData=false) then we cannot access data in test class from the database under all method present in the test class. Under this case annotating a method with @isTest(SeeAllData=true) would not be ignored and you can access database data inside this method.
Let's understand with an example.

@isTest(SeeAllData=false)

public class testclassexample {

static testmethod void testMethodFirst() {

//You cannot access like this now.
contact obj = [SELECT Id, Name from contact where name='test' LIMIT 1];

//You need to create test data
Contact obj=new contact();
obj.name='test';
insert obj;

}

@isTest(SeeAllData=true)


static testmethod void testMethodFirst() {


contact obj1 = [SELECT Id, Name from contact where name='test' LIMIT 1];
//Accessing contact from database although @isTest(SeeAllData=false) is applied for class but it will get ignored.


}

}

**************************************************************************************************************

What is the use of test.isrunningtest()? 


Sometimes it may happen that in test class you are not able to satisfy certain if the condition
so under this case, we can bypass this condition by writing test.isrunningtest().

Syntax:

if(a=3 || test.isrunningtest())
{

}

**************************************************************************************************************

What is batch apex in salesforce? 


Basically, when we want to deal with a large number of records we go for the batch apex.
The code inside batch class runs asynchronously i.e in a future context.
The governor limit is also more as compared to synchronous code.

When we use batch apex we implement Database.batchable() interface


The Database.batchable() contains three methods that we need to define inside the batch class
and they are,
1)start
2)execute
3)Finish

Start method and finish method are called only once inside the batch class.

Start method collects the data for processing.
The execute method performs operations.
Finish method generally used for sending emails or calling another batch class when the current batch is completed.

For more details visit,

Batch class in Salesforce (Click here)

**************************************************************************************************************

What is database.stateful interface? 


Basically batch class does not maintain its state. If we implements Database.Stateful we can maintained state across transactions.Only instance variable holds values static members does not hold values.If we want to count records as batch proceeds maintaining state is important as after 200 records new transaction will start and members will loose their values.

**************************************************************************************************************

How to write Test class for batch class? 



You need to call batch class from inside of test.starttest() and test.stoptest()
with below syntax,

@istest

public class testclass{

static testmethod void methodname1()
{
test.starttest();

batchClassName obj=new batchClassName ();
Id batchId=Database.executeBatch(obj);

test.stoptest();

}


}

**************************************************************************************************************

What is order of exceution in salesforce? 



When we save a record with insert/update/Upsert statement, The following is the order of execution in salesforce,


1)System validation to verify all required fields are supplied.
2)All before trigger
3)System validation again to verify all required fields are supplied.
4)The record is saved but not committed to the database
5)All after trigger
6)Assignment rules
7)Auto response rule
8)Workflow rules
If field update occurs through workflow than,
9)Before trigger
10)After trigger
11)escalation rules
12)Commit dml to database

**************************************************************************************************************

What is action function in visualforce? 


With action function, you can directly invoke the controller method from javascript function using ajax request.


Action function must be called from javascript function or from a client-side event such as onclick.

Syntax:

<apex:actionFunction name="somename" action="{!callControllerMethod}" reRender="someid"/>



Let's take an exxample for creating contact,

Visualforce page:

<apex:page controller="createcontact">
<script>

  function javascriptmethod()
  {

  createcon();
  alert('contact created');

  }
  </script>

  <apex:form id="test">

  <apex:inputText value="{!contactname}"/>
  <apex:commandButton value="Create contact" onclick="javascriptmethod()"/>


  <apex:actionFunction name="createcon" action="{!callControllerMethod}" reRender="test"/>

  </apex:form>
</apex:page>


Controller:

public class createcontact{
public string contactname{get;set;}

public void callControllerMethod()
{

contact obj=new contact();
obj.lastname=contactname;
insert obj;

}

}

**************************************************************************************************************

What is action support in visualforce? 

Basically, we use action support to support another visualforce component,
the events include "onchange", "onclick" etc.

Let's take an example,

Visualforce:

<apex:page controller="createcontact1">


  <apex:form id="test">

  <apex:inputText value="{!contactname}">
  <apex:actionSupport event="onchange"  action="{!callControllerMethod}" reRender="pageblockid"/>
  </apex:inputText>
  <apex:pageblock id="pageblockid">
 <apex:pageBlockTable value="{!contactList}" var="con">
 <apex:column value="{!con.name}"/>


 </apex:pageBlockTable>

  </apex:pageblock>

  </apex:form>
</apex:page>


Controller:

public class createcontact1{
public string contactname{get;set;}
public list<contact> contactList{get;set;}
public void callControllerMethod()
{

contactList=[select name from contact limit 1];

}

}

**************************************************************************************************************

What is view state? 


Suppose we are having a requirement to register a user. If we are having multiple pages
which user need to fill, so under this case we need to maintain the state when the user is moving
from one page to other. For this, we use form tag. Governing limit for the form tag is 135 kb.
To avoid reaching the limit we should declare a variable as static or we need to mention transient
keyword before the variable as this does not occupy the state.

Solutions to reduce view state:


1)Use remote method as it is stateless.
2)use a transient keyword before variable which is not required to be retained as going forward.
3)Avoid form tag if not required as it will not create view state.

By reducing the view state the page load quicker so the performance of the page increases.


**************************************************************************************************************

How to restrict trigger to fire only once(Recursive trigger)? 


Recursion occurs when your trigger fires again and again.
the situation such as when you are using after update trigger and updating parent record and again on parent record, there is a trigger which updates child records. It can lead to an infinite loop.

To avoid this,


We can use a static variable inside helper class with default value as true and once execution is finished inside helper we can set it to false and check it's value inside trigger from where it getting called.

As an example

Inside trigger,

If(helperclassfortrigger.booleanvar) //checking value to avoid second run
{
//calling helper method

}

Inside Helper class,

public class helperclassfortrigger{

public static boolean booleanvar=true;


Public static methodname()
{
booleanvar=false;

}



}

**************************************************************************************************************

Explain concept of static variable and static method in salesforce? 


Static variable in salesforce (Click on the link for complete details)

**************************************************************************************************************

Explain controller in salesforce?

Standard controller in salesforce (Click on the link for complete details)

Custom controller in salesforce (Click on the link for complete details)


**************************************************************************************************************

What is custom setting in salesforce and what are its type? 


Custom setting is similar to the custom object in Salesforce, You can store some custom data inside this and can access this inside apex class avoiding the use of multiple soql queries.

1)List custom setting
2)Hierarchy custom setting

**************************************************************************************************************

How to access list custom setting inside apex class? 


Let's say we have a custom setting called employee where we are storing employee name,roll number.
Let's assume we have some employee information stored in a custom setting as below.

Name                            Roll no

employeeName1          rollNo1
employeeName2          rollNo2

Syntax:

Fetching employee1 details,

Employee__c obj=new Employee__c.getvalues('employee1');

String rollNo=obj.rollNo1__c;

**************************************************************************************************************

What is difference in list custom settings and hierarchy custom setting? 


List custom setting have user-independent values whereas hierarchy custom setting
lets you personalize setting for specific role and profile.

**************************************************************************************************************

what are the methods available with List custom settings? 


Methods available with list custom settings are:

1)getAll();
2)getValues();

Syntax:

1) Map<Data_set_name, CustomSettingName__c> cus = CustomSettingName__c.getAll();

The getAll method returns values from all fields associated with list custom setting.

2)CustomSettingName__c cus = CustomSettingName__c.getValues(Data_set_name);

The getValues method returns values associated with a specific data set.

This method can be used with both list and hierarchy custom settings.

**************************************************************************************************************

what are the methods available with Hierarchy custom settings? 


Methods available with Hierarchy custom settings are:

1)getOrgDefaults();
2)getInstance();

syntax:


1)CustomSettingName__c cus = CustomSettingName__c.getOrgDefaults();

The above method returns values from dataset at the organization level.

2)CustomSettingName__c cus = CustomSettingName__c.getInstance(Profile_ID or UserID);

The above method returns dataset values related to specific profiles.

**************************************************************************************************************

salesforce interview questions,salesforce interview questions and answers,salesforce interview questions pdf,salesforce interview questions and answers,salesforce interview questions for experienced,salesforce interview questions for experienced developer.

**************************************************************************************************************

3 comments: