Salesforce Interview Questions Scenario Based Interview
Salesforce Interview Questions Scenario Based Interview
Salesforce Interview Questions Scenario Based Interview
Code:
2. Whenever Lead is created with LeadSource as Local then give rating as cold
otherwise hot.
Answer: Test.startTest() and Test.stopTest() exist primarily to allow you to reset the
governor limits within the context of your test execution and to be able to test asynchronous
methods. These two statements cannot be called more than once within a testMethod. They
are not required to be used but in some situations may be critical.
4. Let say a user does not have permission on a child object and is having permission on
parent object to read/create/edit/delete parent object, If there is a trigger on parent
object to insert a child record after parent record is created, will it create a child record
or not after the user insert parent record manually?
Answer: Component events are used in cases where there is a relationship between two
components. Component Events are fired by the child components and handled by the parent
component.
6. Suppose we have a requirement to create an account using a new button and some
default values in the new account screen. How can we achieve this requirement?
Answer: We can make use of force:createRecord; it is an event that opens a page to create a
record for a specific entity.
Sample syntax:
7. There is a profile by name ‘ReadAccessProfile’ and two users User1 and User2 have
been assigned to it. There is an object X. I want to have ReadWrite access for User1 and
ReadOnly access for User2 for the object X. How can this be accomplished?
1. Step 1: Read Access for both users is common hence in the Profile settings give ‘Read’ access
for the object ‘X’. By doing this User U2 will be able to read all the records( One condition
satisfied) but User1 will only be able to read the records (Second condition not satisfied).
2. Step 2: So next what we do is we create a permission set say ‘GrantWriteAccess’ and in this
permission set we give the object ‘X’ the Write access and assign the user User1 to this
permission set. (Second condition satisfied).
8. I have two objects Object1 and Object2 which are not related to each other. Now I
want to create a Master Detail Relationship(MDR) between these objects. How can I do
this?
Answer: Scenario 1: If the two objects are new and there are no records in each. Then we
can create a Master-detail relationship by creating the field in Setup.
Scenario 2: If the two objects exist prior to this requirement and have records . If this is the
scenario then we should first create a lookup relationship between the two objects and make
sure that all the values are filled and then convert the relationship to master-detail from
lookup.
9. The requirement is to delete a set of records and don’t want them to be stored in the
recycle bin as well. What are my options?
Answer: This can be done using the Hard Delete option. It can be done in apex by calling
emptyRecycleBin().
10. In the before Insert event trigger which context variable is correct Trigger.new or
new Trigger.newmap?
Trigger.newmap will not be supported as we do not have an id of record before the record is
inserted.
A. Salesforce Fundamentals
1. What is the difference between profile and role? Can a user be assigned two profiles ?
Answer: A Salesforce profile controls the following key aspects pertaining to Salesforce:
Field Level Security – Here, the users are restricted to create, read, edit, and delete fields
according to specific requirements.
Page Layouts – This restricts the page layouts a Salesforce user is permitted to see.
Custom Apps – This restricts all the custom and standard apps that can be viewed and
accessed by a Salesforce user.
Record Types – This restricts the record types available to specific Salesforce users.
Login – This restricts the login hours of Salesforce users onto the platform based on specific
requirements.
Tabs – This restricts the tabs that can be accessed and viewed by the Salesforce users.
There are two major types of user-profiles in Salesforce – standard profiles and custom
profiles. While a standard profile is already provided by Salesforce, a custom profile can be
created by the users based on their specific requirements.
Answer: As we all know, Salesforce is on a shared (multi-tenant) platform which means the
whole resource is shared with everyone who is a client/customer of Salesforce. This requires
Salesforce to enforce some limits of the resource used by each client/customer. These rules
are referred to as Governor Limits. These limits are different according to the license or
version the client/customer has purchased/ subscribed to.
3. Can you edit an apex trigger/ apex class in the production environment? Can you edit
a Visualforce page in the production environment?
Answer: No, you cannot edit and apex trigger or class in production. You need to make the
changes in the dev environment and then deploy it using the deployment tools.
Answer:
A sandbox serves as a copy of the production environment where the developers and testers
can create and test new features and configuration changes without affecting the data or
settings of the production environment.
Answer: A standard profile is a profile assigned to the users by Salesforce. These profiles
cannot be deleted and need to adhere to the Salesforce permission sets assigned to them.
1. System Administrator
2. Standard User
3. Marketing User
4. Solution Manager
5. Read only
6. Contract Manager
6. What are the different types of relationships in Salesforce ? Can you differentiate
between them?
Answer: Relationships depict how two objects are related to each other. Salesforce allows
the following relationships:
1. Master-detail relationship
2. Lookup relationship
3. Many to many relationship
4. Self relationship
5. External relationship
Master-detail relationship: In this relationship one object acts as the master or controlling
object and the other object acts as the detail or the controlled field. When the master object
record is deleted the detail records get deleted along with it.
The master record is required on the detail record. It is a tightly bound relationship. We can
only assign two master-detail relationships per object. We can only create a roll-up summary
field on this relationship.
Lookup relationship: In this relationship the objects are loosely coupled. The object doesn’t
get deleted if the other object is deleted.Parent and child records have their own sharing and
security settings. The lookup relationship is not mandatory by default. We can assign upto 40
lookup relationships per object.
Many to many relationships: There is no such relationship such as many to many but we
can create it by adding two master-detail relationships to a common object. The common
object is also known as Junction object.
Self Relationships: A self relationship is a relationship with the same object. This can be
explained better with an example: A account is related to a parent account.
Answer: SOQL (Salesforce Object Query Language) are used to construct simple and
powerful query strings in the queryString parameter in the query() call, in Apex statements,
triggers, in Visualforce controllers and getter methods, or in the Schema Explorer of the
Force.com IDE. It is similar to SQL with features to query Salesforce objects directly. It can
only search one object at a time. It returns records on which DML operations can be
performed
SOSL ( Salesforce Object Search Language) is used to construct text searches in the
search() call, in Apex statements, in Visualforce controllers and getter methods, or the
Schema Explorer of the Eclipse Toolkit. It can be used to search multiple objects at one time.
It cannot be used in triggers. It returns fields as results. DML operations cannot be performed
on these results.
Answer: A Permission set is a collection of settings and permissions that give users access
to various tools and functions. Permission sets extend users' functional access without
changing their profiles.
Sharing rules are used to extend sharing access to users in public groups, roles, or
territories. Sharing rules give particular users greater access by making automatic exceptions
to your org-wide sharing settings.
1. Change Sets
2. Eclipse with Force.com IDE ( Deprecated)
3. Force.com Migration Tool – ANT/Java based
4. Salesforce Package
5. VSCode Salesforce Extension Pack
6. Salesforce Code Builder
Answer: The minimum test coverage required is 75% to deploy to production. If this is not
satisfied then the apex class or trigger cannot be deployed to production.
B. Lightning Based
1. What does the lightning component bundle contain?
Answer:
1. Component
2. Controller
3. Helper
4. Style
5. Documentation
6. Renderer
7. SVG
8. Design
Answer:
Answer:
The lightning app builder is used to create lightning pages for the Salesforce Lightning
experience and mobile apps. The Lightning App Builder is a point-and-click tool. Lightning
Pages are built using Lightning components which are compact, configurable, and reusable
elements that can be dragged and dropped into different regions of the page in the Lightning
App Builder. It is very useful and easy to use.
1. App Page
2. Home Page
3. Record Page
4. Which language does Lightning component use on Server side and Client side?
Answer: Lightning Component uses Javascript on the client side and Apex on the server
side.
Answer:
Answer:
1. Better Performance
2. Out of the box component set
3. Faster development
4. Multiple device and cross-browser compatibility
5. Event driven architecture
6. Rich component ecosystem
1. Drag and drop components in Lightning App builder and Community builder
2. Quick Action buttons
3. Lightning pages
4. Lightning Record pages
5. Stand alone Apps
6. Overriding standard actions
Answer: A bucket field is a field which helps in categorizing records in a report. It can be
used as any other field to sort, filter or group your report.
Answer: Standard reports are created by Salesforce when we create objects and relationships.
Custom reports fields can be specified by admin. We can also associate upto 4 objects.
4. What is a dashboard?
Answer: Dashboard can be simply put as a graphical representation of reports which can be
tailored to a user and can also be set to a standard representation which is the same for all
users. Dashboards can have upto 20 components. Dashboards show data according to the last
run report.
Answer: Dynamic dashboards are used to display details according to the user’s security
settings. It does not refresh on its own. It refreshes when the page is refreshed. Dynamic
dashboards help to show data which is specific to that user and the data which he has access
to.
Answer: Yes formula fields can be used in all the other types of reports except Tabular.
Formula should be in currency, percent or number type.
Answer:
1. Bucket fields
2. Cross filters
3. The rows to display filters.
Answer: Apex triggers allow us to perform custom actions before or after events to records
in Salesforce, such as insertions, updates, or deletions. We use triggers to perform tasks
which can’t be done by other point and click tools in Salesforce UI. There are two types of
Triggers:
Answer: Process builder is a simple to use workflow tool to automate your business process.
It provides a simple graphical representation which depicts the process. Process builder can
be used to
1. Create a record
2. Update the record
3. Launch a flow
4. Send an email
5. Post to chatter
6. Submit for approval
7. Can do what all a workflow can do except for outbound messages
3. What is a workflow? What actions can be performed using it?
Answer: Approval process is used to provide the user a step by step guide to approve a
certain process. We can configure to send an email, create a task etc when the approval
process reaches a certain step of the process. The approval process consists of the following
steps:
1. Process definition
2. Initial submission actions
3. Step definitions
4. Final Rejection actions
5. Final Approval actions
Answer: Recursive trigger is a situation where the actions of the trigger invoke the same
trigger and it goes on in a loop.To avoid this scenario a simple step is to create a static
variable and check the state of the variable before executing the trigger.
Answer: Simply put the process builder is designed to be the simpler tool. It is much linear in
process as compared to Flow builder. Flow builder is much more powerful not only in terms
of the process design but also actions. Flow builder has a delete functionality along with
being able to update multiple records. It is true that process builders are also able to update
multiple records but it is limited in updating only child records of the parent record which
started the process.
7. What are the conditions which need to be specified when we need to schedule actions?
8. What is a queue?
Answer: A queue is used to hold a predefined set of objects and users. Anyone in the queue
can pick up a task assigned to the queue and can complete it. A queue can contain users,
public groups, partner users, roles, roles and subordinates etc.
9. What are context variables and how do we use them?
Answer: Trigger Context variables (TCV) can be defined as those variables which help us in
tracking the runtime information of the current execution of a trigger.Some of them are:
1. isExecuting: This variable returns the value true if the current context for the Apex code
happens to be a trigger and does not happen to be a Visualforce page, a Web service, or an
execute anonymous() API call.
2. isInsert: This variable returns the value true if the trigger executed is an insert operation
3. isUpdate: This variable returns the value true if the trigger executed is an update operation
4. isDelete: This variable returns the value true if the trigger executed is a delete operation
5. isBefore: This variable returns the value true if the trigger was fired before any record was
saved
6. IsAfter: This variable returns the value true if the trigger was fired after all record was saved
7. isUndelete: This variable returns the value true if the record was recovered from recycle bin
8. new: This variable returns the list of the new versions of the sObject records. This is only
available in insert, update and undelete triggers.
9. newMap: This returns the list of Ids of the new version of the sObject records
10. old: This variable returns a list of all the old versions of the sObject records. This is only
available in update triggers and delete triggers
11. oldMap: This variable returns the list of Ids of the old versions of the sObject records
12. size: This is variable returns the total number of records invoked by the trigger
10. What is the order of execution of Trigger, Process Builder and workflow?
Answer: The order of execution is Trigger => Workflow => Process Builder
1. User interface integration: Combine the UIs of two or more apps to create composite apps
with little or no rework on the UI of each individual app.
2. Business Logic Integration: Apex Web Services is used for Inbound and Apex Callouts for
Outbound. It typically handles a scenario where business logic is spread across several
applications to implement the complete end-to-end business process.
3. Data Integration: SOAP APIs and REST APIs are used here. It typically handles data
synchronisation requirements, where one application in an enterprise acts as the primary
source for a particular business object, like Account.
3. How many APIs are available in Salesforce?
REST API
SOAP API
Bulk API
Streaming API
Metadata API
Chatter REST API
User Interface API
Analytics REST API
Apex REST API
Apex SOAP API
Tooling API
4. What is webservices?
5. What is JSON?
Answer: JSON (Javascript Object Notation). JSON is lighter than XML . When transferring
data between two communication channels it needs to be in Text, JSON is text and can be
converted to Javascript and vice-versa with ease. JSON is then used to send messages
between servers.
Answer: Test classes are used to write unit tests for Apex classes and triggers in salesforce.
We need to write test classes which have more than 75% code coverage of the apex class and
triggers. When we need to deploy apex classes or triggers in production we need to upload
the test classes along with it . If the test classes fail to cover 75% of the code then deployment
fails.
Answer:
@isTest
private class MyTestClass {
static testMethod void myTest1() {
}
static testMethod void myTest2() {
}
}
1. system.assertEquals(val1,val2)
2. system.assertNotEquals(val1,val2)
3. system.assertEquals(val1> val2)
9. What is seeAllData?
Answer: The test classes cannot recognise the data in the database by default and hence we
need to mention the @isTest(seeAllData=true) so that it recognised the data in the database.
1. Single records
2. Bulk records
3. Positive scenarios
4. Negative scenarios
5. Restricted User
Answer: LWC is a new programming model to help developers build Lightning components
for Salesforce. It makes use of Javascript more and does not use Apex making it easier for
developers with javascript knowledge to build components in salesforce without any apex
knowledge. It is much faster and lighter as it uses Javascript. The lightning component bundle
contains :
1. HTML
2. Javascript
3. XML
Files by default when we create a new LWC component. We need Salesforce CLI to work
with LWC.
Answer:
Wired apex methods- are called every-time the page refreshes or the reactive properties are
changed .Data returned is immutable. We can only perform Read query operations using
wired apex methods. We need to use @wired in front of the function name. If we want to
refresh then we have to call refreshApex().
Imperative apex methods - need to be called explicitly.Data returned is mutable.We can
perform DML operations on imperative operations.DML operations cannot be done if the
apex method is annotated with cacheable=true .It is invoked as promises inside a function.
Answer: @api is used if we need to make the property or function to be public. @track was
used to make it reactive but since Summer 19 release all properties are reactive by default.
Now @track is used to re-render arrays or objects as it does not render by default if one
element of the array is changed or the object’s property is changed.
Answer: No , we cannot use Aura inside a LWC but the opposite can be done i.e we can use
LWC inside the Aura component. We can also use LWC inside flows, page components etc.
Answer:
String
Integer
Boolean
Decimal
Double
Long
DateTime
Date
Array
List
Set
Map
sObject
6. How many events do we have in Aura components? How are they used?
7. What is Visualforce?
Answer: Visualforce is a component based framework that is using tag based markup
language like HTML. The framework is based on the MVC paradigm where controllers can
be generated automatically and integrated with the database.
8. What is a visualforce controller. What are they used for?
Answer: Visualforce controllers helps us in handling what happens when a user performs a
certain function such as clicking a button or link.There are 3 different types of controllers:
Answer: A wrapper or container class is a class, data structure, or an abstract data type
whose instances are a collection of other objects.It is a custom object defined by Salesforce
developer where he defines the properties of the wrapper class. Within Apex & Visualforce
this can be extremely helpful to achieve many business scenarios within the Salesforce CRM
software.
Answer: Static resources help us in uploading documents, files, images, libraries archived
as .zip, and .jar files. These can be later referenced in Visualforce pages or lightning pages.
These static resources are references using $Resource variables.