Top 50 Salesforce Interview Questions You Must Prepare 02.Mar.2024


  • Trigger is a piece of code that executes before or after a record is inserted or updated.
  • We can access the trigger across the object and related to that objects.
  • We can use 20 DML operations in one trigger.
  • We can use 20 SOQL from data base in one trigger.


  • Workflow is automated process that fired an action based on Evaluation criteria and rule criteria.
  • We can access a workflow across the object.
  • We cannot perform DML operation on workflow.
  • We cannot query from database.

  • Apex is a strongly typed object-oriented programming language.
  • It allows the developer to execute flows and transaction control statements.
  • Apex enables developers to add business logic to most system events like button clicks related record updates and visualforce pages.

  • When you want to call apex class in visualforce page we have to declare in the following format.
  • < Apex : page controller = “class name “ >
  • Whenever we call  a visualforce page in which controller attribute is  defined it will first create an object for the apex class which is defined in controller.
  • When object is created for the apex class first it involves the constructor.

Yes possible. Controlling field should be Check box or pick list.

A setting that defines when time-dependent workflow actions should fire.

  • An app is a group of tabs that work as a unit to provide functionality. Users can switch between apps using the app drop-down menu at the top-right corner of every page.
  • You can customize existing apps to match the way you work or build new apps by grouping standard and custom tabs.
  • Navigation to create an app in Salesforce: Setup ->Build ->Create->App-> Click on new and create your application according to your requirements.

We can customize different things on page layout like, Fields, Buttons, Custom Links and Related Lists. We can also create sections.

Public websites and applications that are directly integrated with your salesforce organization without requiring users to log in with a username and password.

Tab is a user interface component to user creates to display custom object data.

There are three type of tabs:

  • Custom Tabs
  • Visual force Tabs
  • Web Tabs

To use javascript remoting in a vf page , add the request as a java script invocation with the following from.

[namespace.] controller.method ( 


                            Call back Function,



  • Name space is the namespace of the controller class
  • Controllers is the name of your apex controller.
  • Method is the name of your apex controller method you are calling.
  • Parameters is the comma-separated list of parameters that your method takes.
  • Callback function is the name of the javascript function that will handle the response from the controller.
  • Configuration configures the handling of remote call and response.

Role Hierarchy:

  • If we add a user to a role, the user is above in the role hierarchy will have read access.
  • Setup --> manage users --> roles --> setup roles --> click on ‘add role’ --> provide name and save.


  • Defines the base line setting for the organization.
  • Defines the level of access to the user can see the other user’s record
  • OWD can be Private, Public Read Only, Public Read and Write.
  • Setup -> Security Controls -> sharing settings -> Click on ‘Edit’

Manual Sharing:

  • Manual Sharing is sharing a single record to single user or group of users.
  • We can see this button detail page of the record and this is visible only when OWD setting is private.

Criteria Based Sharing rules:

  • If we want to share records based on condition like share records to a group of users
  • Whose criteria are country is India.
  • Setup -> security controls -> sharing settings -> select the object and provide name and Conditions and save

Apex sharing:

Share object is available for every object(For Account object share object is AccountShare ). If we want to share the records using apex we have to create a record to the share object.

Record Types are restrict the pick list values and assign to the different page layouts for different Record Types.

 Standard controller, select option, pagereference, messages,etc.

  • Visual force page
  • Web Service
  • Triggers
  • Email services

If we want to give access to other users we use sharing rules.

Yes. Just like S-Controls. Visualforce pages support embedded merge fields.

We can use database.executebatch ( ) method to programmatically begin the batch job.


Public static ID execute batch ( sObject class name)

Public static ID execute batch (sObject class name, integes scope) 

The above two methods are static methods of database class. We can use any one of the method to execute the batch job.

We are having two types of relationships, they are:

  • Lookup Relationship
  • Master-Detail Relationship

According to the field selection on one field filter the pick list values on other field.

Batch Apex:

Batch Apex allows you to define a single job that can be broken up into manageable chunks, whereas every chunk can be processed separately.

With  ApI version 18.0 and  later /you can use group by with aggregate functions, such as sum() or max() to summarize the data and enable you to rollup query results rather than having to process the individual records in your code.

    Syntax : 

          [ GROUP BY field GROUP BY LIST]

  • Integrated: It provides built-in support for DML Calls
  • Inline Salesforce Object Query Language
  • Easy to Use
  • Easy to Test
  • Version
  • Multi Tenant Aware Application

  • To create Email services
  • Create web services
  • Perform complex validation over multiple objects
  • To create complex business processes that are not supported by workflow
  • Create custom transaction logic
  • Attach custom logic to another operation

SOSL statement evaluate to a list of sobjects , where each list contains the search results for a particular sobject type, The result lists are always returned in the same order as they were specified in the query.

If a SOSL query does not return any records for a specified sObject type , the search results include an empty list for that sObject.

For example, you can return a list of accounts, contacts, opportunities and leds that begin with the phase map.

Note : 

The syntax of the classon Apex differs from the syntax of the FIND clause in the SOAP API.

In Apex, the value of the FIND cause is demarcated with single quotes.


FIND 'map*' IN ALL FIELDS RETURNING account (Id, Name], Contact, Opportunity, Lead.

In the API, the value of the FIND Clause is demarcated with braces.


FIND {map*} IN ALL FIELDS RETURNING account  [Id,name], contact ,opportunity,lead.

From search list , you can create arrays for each object returned.

Account [ ]  accounts = (( list < accounts > ) search list [0] );

Contact [ ]  contacts = [( list ) search list [0]) ;

Opportunity [ ] opportunities = ((list < opportunity> ) search list [2]) ;

Lead [ ] leads = (( list < lead> ) search list [3]);

A protocol that defines a uniform way of passing XML-encoded data. SOAP Stands for Simple Object Access Protocol.

  • A Wrapper class is a class whose instances are collection of other objects.
  • It is used to display different objects on a VF (Visual Force) page in same table.

Action function

Invoke the controller method from java script using AJAX and we can use action function from different places on visual force page.

Action support:

Invoke the controller method using AJAX when even occurs on page like onMouseOver, onClick, ect… and we can use action support for particular single apex component.

Page Block:

For default salesforce standard format.

Data table:

To design custom formats.

A Batch class allows you to define a single job that can be broken up into manageable chunks that will be processed separately.

One example is if you need to make a field update to every Account in your organization. If you have 10,001 Account records in your org, this is impossible without some way of breaking it up. So in the start() method, you define the query you’re going to use in this batch context: ‘select Id from Account’. Then the execute() method runs, but only receives a relatively short list of records (default 200). Within the execute(), everything runs in its own transactional context, which means almost all of the governor limits only apply to that block. Thus each time execute() is run, you are allowed 150 queries and 50,000 DML rows and so on. When that execute() is complete, a new one is instantiated with the next group of 200 Accounts, with a brand new set of governor limits. Finally the finish() method wraps up any loose ends as necessary, like sending a status email.

So your batch that runs against 10,000 Accounts will actually be run in 50 separate execute() transactions, each of which only has to deal with 200 Accounts. Governor limits still apply, but only to each transaction, along with a separate set of limits for the batch as a whole.

Disadvantages of batch processing:

  • It runs asynchronously, which can make it hard to troubleshoot without some coded debugging, logging, and persistent stateful reporting. It also means that it’s queued to run, which may cause delays in starting.
  • There’s a limit of 5 batches in play at any time, which makes it tricky to start batches from triggers unless you are checking limits.
  • If you need access within execute() to some large part of the full dataset being iterated, this is not available. Each execution only has access to whatever is passed to it, although you can persist class variables by implementing Database.stateful.
  • There is still a (fairly large) limit on total Heap size for the entire batch run, which means that some very complex logic may run over, and need to be broken into separate batches.

  • No, directly we cannot create master-details relationship if a custom object contains existing records.
  • Following are the steps to create to create a master-detail relationship when records are available in a custom object.
  • First create field with lookup relationship.
  • And then associate look field with parent record for every record next change the data type of the field from look up to Master detail.

Email services is an automated process that use Apex classes to process the contents, Headers, Attachments of Inbound Email.

While you can instantiate a class based on its name using the Type system class, you can’t dynamically locate a method and execute it. The best that you can do is to dynamically create an instance of a class that implements an interface and executes one of the methods on the interface.

A web directory where hundreds of appexchange apps  are  available to salesforce customers to review, demo, comment upon, and /or install. Developers can submit their apps for listing on the appexchange directory if they want to share them with the community.

  • Map Class Contains methods for the Map collection type.
  • A Map is collection of key values pairs where each unique key maps to a single value. 
  • Map keys and values can be any data type primitive types, collections, sObjects, users defined types, and built in Apex Types.

An app development model that allows apps to be defined as declarative "blueprints”, with no code required. Data Models, objects, forms, workflows, and more are defined by Metadata.

  • Use javascript remoting in visualforce to call methods in apex controllers from javascript.
  • Javascript remoting has 3 parts.
  • The remote method invocation you add to the visualforce page, written in javascript.
  • The remote method definition in your Apex controller class.
  • This method definition is written in apex, but there are  few differences from normal action methods.
  • The response handles callback function you add to or include in your vf page, written in javascript.

Apex-lang is about as close to a Java-style library as you can get. Contains several string, database, and collection utilities that mimmick Java functionality. Be aware though, some stuff including Comparing and Sorting collections is out of date with the advent of the Comparable interface in Apex.In addition to apex-lang, and like you suggest, I typically create or reuse static helper methods throughout my projects. Static helper methods are very convenient for reusing code in Chatter functionality, DML handling, Exception handling, Unit testing, etc.

  • Use the future annotation to specify that these methods that are executed asynchronously.
  • Methods with future annotation must be static methods
  • Methods with future annotation can only return a void type.


global class class_name



Static void methodname(parameters)


//body of the method


  • You can create sObjects in memory with arbitrary CreatedDate values by using JSON.deserialize. This doesn’t enforce the normal read-only field attributes that prevent you from setting a createdDate value. However, you can’t commit arbitrary CreatedDate values to the database (or else it would be a serious security issue).
  • Detecting governor limits through apex
  • First of all, the exception thrown by hitting a limit, System.LimitException is uncatchable and means that your script will be killed, even if it happens inside a try/catch block. There is a class, Limits, that contains a number of static methods that allow you to check your governor limit consumption.

Yes,user can upload their custom logo in documents and then they choose that logo for organization.

  • Objects are database tables that allow you to store data specific to your organization in salesforce. You can use custom objects to extend functionality or to build new application functionality.
  • When you create a custom object, we can create a custom tab, customized related lists, reports, and dashboards for users to interact with the object data. You can also access custom object data through the API.
  • Navigation to create an object in sales force: Setup-->Build-->Create-->Object--> Click on new object and create object according to your requirement.

  • All Apex programs runs entirely ON-Demand on Platform.
  • First the platform application server compiles the code into abstract set of instructions that can be understood by Apex runtime interpreter.
  • The compile code is stored to metadata.
  • When the end users triggers the execution of Apex by clicking button or visualforce page the application servers retrieves the compiled instructions from the metadata and send them to runtime interpreter before returning the result.

There are 4 types of reports in Salesforce:

  • Tabular Reports
  • Summary Reports
  • Matrix Reports
  • Joined Reports

S-Controls are the predominant widgets which are completely based on JavaScript. These are hosted by salesforce but executed at client side. S-Controls are superseded by VisualForce now.

Salesforce Object Query Language is used to query that records from the based on the requirement.

There are 2 types of SOQL Statements:

  • Static SOQL
  • Dynamic SOQL

1.Static SOQL:

  • The oStatic SOQL Statement is written in []  (Array Brackets)
  • This statements are similar to IINQ(Ion Integrated Query)

2.Dynamic SOQL

  • It is used to refer to the creation of a SOQL string at run time with Apex code.
  • Dynamic SOQL enables you to create more flexible application.
  • To create Dynamic SOQL query at run time use Database.Query() method, in one of the following ways.
  • Return a single sObjects when the query returns a single record. ex:sObjects s = Database. Query(String_limit_l);
  • Return a list of sObjects when the query returns more than a single record.

An application model in which all users and apps share a single, Common infrastructure and code base.

There are a couple of decent Dreamforce presentations here:

Team Development:

Possible, Probable, and Painless and Continuous Integration in the Cloud.

We ran into some issues with this in practice and there was no way to get true automation (i.e., set it and forget it). We were also set it up with Selenium.

Here were the issues that I remember:

  • Some features aren’t supported in the metadata API and cannot be moved via the ant migration. If you have any unit tests that work with those features, you have to manually work on your CI org.
  • Deletions are harder to maintain. You have to manually update and apply a destructiveChanges.xml file or replicate the deletion in the CI org.
  • We ran into a situation where some metadata XML files had ‘invalid’ data in them. The suggested solution was to build a post checkout script that manipulates the offending XMLs into valid XMLs. Not ideal.
  • On projects, we wanted to track just our changes and push out just our changes in source control. In theory, this would allow much easier rebase lining. This would have required more manual maintenance of XML files (e.g., 2 new fields added on Account and only want to push those 2 fields not all (*) fields).
  • My conclusion is that it is worth doing if you can get it set up, but if you are working on shorter-term projects and don’t have a decent amount of time budgeted in for it, it probably isn’t worth setting up.

SOQL:(Salesforce Object Query Language)

  • Using SOQL we can Search only on one object one time.
  • We can query on all fields of any datatype
  • We can use SOQL in the Triggers and the classes.
  • We can perform DML operation on sql query results.

SOSL:(Salesforce object Search Language)

  • Using SOSL we can search on many objects at one time.
  • We can query only on fields whose data type is text,phone and Email.
  • We cannot use in Triggers but can in classes.
  • We cannot perform DML operation on search results.

The transient keyword prevents the data from being saved in to view state. This should be used for very temporary variables.

It will invokes the Apex class to run at specific time.

Anybody who want to schedule their class they have to implement schedulable interface.

Schedule Interface:

The class that implements this interface can be scheduled to run at different intervals. This interface has several methods.

They are:

Public void execute(schedulablecontext sc) etc.