Salesforce Interview Questions
Salesforce Interview Questions
1. Developer Sandbox
3. Partial Copy
4. Full Sandbox
Simply put, cloud computing is a way of accessing services on the internet instead of on
your computer. You can use the cloud to access applications, data, and development
tools from virtually anywhere. Whether you’re working on your phone from a crowded
train in Chicago or on your laptop at a hotel in Hong Kong, you can access the same
information because it all lives online.
3. What is Iaas?
IaaS stands for Infrastructure as a service: A cloud service provider owns and
manages the hardware upon which your software stack runs. That includes servers,
networking, and storage. This can be a great cost-reduction strategy if you’d like to avoid
purchasing and maintaining infrastructure.
In this type of service, you will get the Virtual System that can be connected using the
internet. Where you can install any Software even in some service providers you can
install the operating system.
4. What is PaaS?
PaaS stands for Platform as a service: In this type of service, you get a development
platform bundled with all the types of software preinstalled. You will then have to write
and execute all your codes in a remote server by some mechanism.
5. What is Saas?
SaaS stands for Software as a service: It offers the most support and is the simplest of
all delivery models for the end user. Chances are that you already use it in your
organization. This is the highest level of service in which everything is provided from
hardware to software to already build applications.
1. Lookup Relationships
2. Master-Detail Relationship
4. Self Relationship
5. External Relationships
6. Hierarchical Relationships
A junction object is a custom object with two master-detail relationships, and it is the
key to making a many-to-many relationship.
Profiles help to control object privileges such as CRED (Create, Read, Edit, Delete).
They also contain system permissions that a user can carry out such as exporting data.
Profile used for object level and Field level access. It is mandatory for all Users.
Roles on the other hand help with sharing records across an organization. They work in
a hierarchical fashion, giving users access to records that are owned by people lower
down in the hierarchy. Roles used for Record level access. It is not mandatory for all
Users.
2. View All and Modify All permission on the profile or permission set
3. Profile level System Permission.
5. Record Ownership
6. Role Hierarchy
8. Queues
9. Sharing Rules
10. Groups
Sharing rules in Salesforce are used to create automatic exceptions to the Organization-
Wide Default settings for the users who do not own the record.
They should be applied to the objects whose org-wide defaults are set to Public Read-
only or Private because sharing rules can only extend the access they cannot restrict
the access provided by Organization-wide defaults.
There are 2 types of Sharing Rules in Salesforce based on which records to be shared:
• Owner Based
• Criteria Based
There are situations where the business requirement is too complex and standard
sharing rules provided by the Salesforce will not work. In that case we can use the Apex
Sharing.
To access sharing programmatically, you must use the share object associated with the
standard or custom object for which you want to share. For example, AccountShare is
the sharing object for the Account object and for MyCustomObject it should be like
MyCustomObject__Share. Here is sample code. Learn more about Apex Sharing.
myCustomObject.ParentId = recordId;
myCustomObject.UserOrGroupId = userOrGroupId;
myCustomObject.AccessLevel = 'Read';
myCustomObject.RowCause =
Schema.MyCustomObject__Share.RowCause.Manual;
Database.SaveResult[] jobShareInsertResult =
Database.insert(myCustomObject,false);
Flow is an automation tool provided by Salesforce which can be used to perform various
tasks like Sending Emails, Posting chatter, Sending custom Notifications &, etc using
clicks instead of code. Check Salesforce Flow Builder training if you are new.
4. Platform Event Flow: Launches when a platform event message is received. For
example, you can pump the data from an external system in Platform Events and
then use Flows to split and save the records in different objects.
5. Auto launched Flow: Launches when invoked by Apex, Process Builder or even
REST API
Try not to mix Apex, Process Builders, Workflow Rules, and Record-Triggered flows. In
general, you should choose one automation tool per object.
let declarative tools handle non-DML activities like email alerts and in-app separate DML activity a
alerts Apex
10. Dont mix Trigger, Process Builder, Flow and Record Trigger Flow
Let’s see the Salesforce platform Apex interview questions and answers:
One common approach is to separate DML activity and offload it to Apex, and let
declarative tools handle non-DML activities like email alerts and in-app alerts — just be
careful and ensure none of your Apex conflicts.
Apex code is used to write custom and robust business logic. As with any language,
there are key coding principles and best practices that will help you write efficient,
scalable code. Check our Apex best practices of Salesforce.
18. What is Apex Trigger? and When we should use Apex Trigger?
There lots of automation tool available in Salesforce. Lets understand the when to use
Apex Trigger in Salesforce.
Check this blog post to learn about which all trigger patterns are available in Salesforce.
For Trigger Handler code check this post.
20. What is Apex Trigger Framework? What are different Trigger Framework are
available in Salesforce?
How many trigger frameworks are available in Salesforce, which one is a lightweight
apex trigger framework and a Comparison of different approaches? Check our Apex
hours Trigger Framework in Salesforce sessions.
21. What is Async Apex in Salesforce? How many ways do we have for Async
processing?
2. Queues
3. @future
6. Continuations (UI)
Batch class is used to process millions of records with in normal processing limits. With
Batch Apex, we can process records asynchronously to stay within platform limits. If
you have a lot of records to process, for example, data cleansing or archiving, Batch
Apex is probably your best solution. In Batch Apex each transaction starts with a new
set of governor limits, making it easier to ensure that your code stays within the
governor execution limits
23. What is the difference between the Stateful and Stateless batch jobs?
In Short, if you need to send a mail to check the number of records passed and failed in
the batch job counter, in that case, can you Stateful batch job?
If you want to create one counter and share/ use it in each execute method use the
same.
A Mixed DML operation error occurs when you try to persist in the same transaction
and change to a Setup Object and a non-Setup Object. For example, if you try to
update an Account record and a User record at the same time.
Use Lightning Data Service to load, create, edit, or delete a record in your component
without requiring Apex code. Lightning Data Service handles sharing rules and field-
level security for you. In addition to simplifying access to Salesforce data, Lightning
Data Service improves performance and user interface consistency
27. How to call Apex class in Lightning web component and how many way we have
and when to use which option?
You can call the apex methods as functions into the component by calling either via the
wire service or imperatively. To call an Apex method, a Lightning web component can:
• Wire a property
• Wire a function
To expose an Apex method to a Lightning web component, the method must be static
and either global or public. Annotate the method with @AuraEnabled
Learn more from the Call apex method from the Lightning web components post.
28. What are the basic difference between Application Event and Component Event
in Aura component?
Application Events are handled by any component have Component Events can be handled b
handler defined for event.These events are essentially a component or a component that inst
traditional publish-subscribe model contains the component
We use attribute type="APPLICATION" in the aura:event tag for We use attribute type="COMPONEN
an application event. the aura:event tag for a component e
Lightning Message Service (LMS) allows you to communicate between Visualforce and
Lightning Components (Aura and LWC both) on any Lightning page. LMS API allow you to
publish message throughout the lightning experience and subscribe to the same
message anywhere on lightning page.
30. What is lazy loading in LWC and how do lazy loading in LWC?
Learn how to use lazy load in the lightning web component here.
We can use Design Attribute to make lightning web components attribute available to
System Admin to edit Lightning App Builder or Community. So we can expose the
component attribute in Lightning App Builder using design Attribute.
Here is a list of the most frequently asked Salesforce Integration question in the
Developer Interview.
Designed with large enterprise application in mind Designed with mobile devices in m
34. What is the difference between Enterprise WSDL and Partner WSDL?
Changes if custom field or custom objects are Does not changes if custom field or custom object
added to your organization organization’ Salesforce configuration
1. OWD – It’s the baseline level of security. Here we define the default level of
access that a user gets on records they don’t own. We have a different option
which defines which level of access would be given: Private, Public Read-Only,
Public Read/Write, Public Read/Write/Transfer.
2. Role hierarchy – In this option user gets access to the record owned by other
users in roles below them. As this option is used to open up the security given by
OWD it extends the access when the Sharing Setting is set to not more restrictive
than Public Read/Write. So if OWD is set to Public Read/Write so there is no need
to give access from Role Hierarchy.
3. Sharing Rules – They are used to give access to records to the user based on
ownership or some criteria. It opens up access compared to Role Hierarchy. So
while creating we have two options: Based on the record owner and Based on
criteria. For example: if we have to provide access to some user if Opportunity
moves to Closed Won then we can achieve this scenario by use of Sharing Rules.
Question 3. Suppose I have a scenario where I have one master detail relationship
between A(master) and B object. Currently, the OWD of A is public read-only and
now I have changed the relationship to lookup. What will be the OWD now of B
object?
Answer – In the master-detail relationship, the child sharing setting will be controlled by
a parent but when we update the data type to lookup, the child object (B) OWD will be
updated to Public Read/Write.
Question 5. What are the different types of trigger and context variables we have in
Salesforce?
Answer – In Salesforce we have two types of triggers which are before and after which
define whether the trigger executes before or after the record gets saved to the
database. Following are the different types of context variables we have in Trigger:
1. isInsert
2. isUpdate
3. isDelete
4. isBefore
5. isAfter
6. New
7. Old
8. oldMap
9. newMap
10. isExecuting
11. isUndelete
12. operationType
13. size
Answer – Recursion occurs when the trigger invokes itself in a loop and eventually hits
the governor’s limit due to repeated execution and iteration. We can also encounter the
error “Maximum trigger depth exceeded” due to multiple executions because the stack
depth limit in Salesforce is 16.
For Example: If a trigger is firing on an Account’s update and in that trigger logic we are
updating those Accounts then it will lead to recursion due to multiple executions.
1. Static Boolean variable – We will use the boolean variable make it default true,
and check the value if true, will enter it into the transaction and make it false
afterwards.
2. Static Set – In this process we will store the processed ID and check if the ID is
contained in the Set or not.
3. Static Map – Here, we will create a Map of String and Set of Id (Map<String,
Set<Id>>) to store the processed Id with their event.
4. Static Old Map – We will use the old map to compare the values before
executing.
Question 7. Write a trigger to calculate the total contact that the Account has and
also include all applicable context variables.
Answer – To achieve this scenario we have two ways. Firstly we create our trigger on
Contact as shown below
ContactTrigger.apxt
trigger ContactTrigger on Contact (after update, before update, after insert, before
insert, after delete, before delete, after undelete) {
if(Trigger.isAfter) {
ContactTriggerHandler.updateContactCount(Trigger.newMap, Trigger.oldMap);
}}}
Here we are using After because we are performing operation on a related object. This
scenario will be applicable to Insert, Update, Delete and Undelete. It is better to have
trigger logic less which means it is a best practice to write any logic in the trigger so
that’s why we have used a helper class here as “ContactTriggerHandler”. Below is the
code for this helper.
ContactTriggerHandler.apxc
if(newMapContactById != null) {
if(con.AccountId != null) {
if(oldContact.AccountId != con.AccountId) {
accountIds.add(oldContact.AccountId);
}}
accountIds.add(con.AccountId);
}}}
if(oldMapContactById != null) {
accountIds.add(con.AccountId);
}}
acc.Id = (Id)agg.get('AccountId');
acc.No_of_Contact__c = (Double)agg.get('countId');
accountsToUpdate.add(acc);
}
try {
update accountsToUpdate;
}}
catch(Exception e) {
}}}
Above the is code to update the Account with the number of contacts. Here we have
created the custom field to update the count No_of_Contact__c. We have utilised
Aggregate SOQL here to calculate the count.
Below is another way of updating the Contact count in the Account without using
Aggregate SOQL.
acc.No_of_Contact__c = acc.contacts.size();
accountsToUpdate.add(acc);
Question 8. Suppose I have a scenario where I want to restrict the user from
updating the Account record multiple times if the record is already updated within
that 1 hour. Write a trigger for this scenario
Answer – Here we have to apply validation to restrict users to update accounts within
the same hour. So we will be using before type here.
AccountTrigger.apxt
trigger AccountTrigger on Account (after update, before update, after insert, before
insert, after delete, before delete, after undelete) {
AccountTriggerHandler.restrictAccountUpdate(Trigger.oldMap, Trigger.newMap); }
AccountTriggerHandler.apxc
if(newAccountMap != null) {
if(oldAccountMap != null) {
}}}}}}
OUTPUT
Answer – We can use this in class to determine whether sharing rules should be
enforced or not.
With Sharing – When we want to run our apex class in respective of the Sharing rules of
the current user then we use it. Below is the syntax of how we can apply it.
Without Sharing – When we don’t want to run our apex class in respective of the
Sharing rules of the current user’s then we use it. Below is the syntax of how we can
apply it. It is a best practice to always use the class in with sharing until and unless
there is a specific requirement to use without sharing.
Also, it only applies to share and does not enforce the field and object level security. If
we want to enforce those we have to explicitly apply it. For example: If the user does not
have access to obj A so even though the class is running without sharing user will not
get access to obj A.
Question 10. In continuation of the above question, does the apex trigger run with
sharing or without sharing?
Answer – Apex triggers can’t have an explicit sharing declaration and run as without
sharing.
Question 11. I have two Apex classes A and B. A is OuterClass which is called B so
that will be an InnerClass. A is running in with sharing context and B is running
without sharing context. Now B has a method inside it, So in which context will that
method be running?
Answer – Class B’s method will run without sharing context and will not depend on the
outer class. Inner classes do not inherit the sharing setting from their container class.
Answer – Row cause in sharing in Salesforce used in Apex sharing. It basically stores
the reason why a particular record is being shared with a user or a group.
Question 13. Write an SOQL to fetch all Accounts which is not associated with any
contacts
Answer – To execute this SOQL we will use the NOT operator in SOQL. Below is the
SOQL we used. Here we have used NOT IN and then we have also used another query
which basically gives the AccountId from Contact. So it will filter out the Account whose
ID is not there in any contacts.
1
SELECT Id, Name FROM Account WHERE Id NOT IN (SELECT AccountId FROM Contact)
Question 14. I have a scenario where I want to fetch the Account with second
second-highest Annual Revenue.
Answer – To implement this scenario we can OFFSET and LIMIT available in SOQL.
OFFSET basically removes the n record from the list. LIMIT gives us only n record.
So to show you I have also executed another SOQL which is ordered by Annual Revenue
in Descending order and we can see “Express Logistics and Transport” coming as the
second highest.
Now to just fetch the second highest only we can use the below SOQL.
Question 15. How can we enable field security while implementing our SOQL?
I have a field called Rating on Account which is having 3 picklist values: Hot, Warm, and
Cold. I want to write a SOQL query to fetch the counts of each value. Like I want to know
how many records have a Rating Hot value in the Rating field and so on for each value.
SELECT Count(Id), Rating FROM Account WHERE Rating != null GROUP BY Rating
Question 17. How can we fetch the current user’s ID in LWC without using Apex?
Answer – To fetch the current user’s ID in LWC we can use the salesforce module and
we can import the ID from it. Below is the sample JS
Question 18. Suppose we have a field on Account as Active of type picklist and has
2 values: Yes, No. While creating the value we can provide any value amongst this
picklist but once we update it to Yes, It can’t be moved to No. How can we
implement this scenario?
Answer – To implement this scenario we make use of the before update trigger. Below is
the helper class logic we can use
}}}
Suppose I have a sharing rule by which User A is getting access to certain records as
that user is part of a certain group which is mentioned in the sharing rule. Now I want to
limit access to a few records that have matching criteria from User A. How can I
implement this scenario?
Answer – To implement this scenario we can make use of Restriction Rules. These are
available on custom objects, external objects, contracts, events, tasks, time sheets,
and timesheet entries. They basically apply a filter to the records shared via OWD or
another share mechanism. We can have up to 2 restriction rules per object.
Question 20. What is mixed DML error and when do we encounter it??
Answer – We encounter this error whenever we are performing DML operations on the
Setup and Non-Setup objects in a single transaction due to which sharing is getting
recalculated then only we face this error. Let’s take a look at the below code to
understand it clearly.
insert a;
emailencodingkey='UTF-8', lastname='Geek',
languagelocalekey='en_US',
timezonesidkey='America/Los_Angeles',
username='test@geek.com');
insert usr; }
Here, we are inserting Account and User both in a single transaction and we are
assigning user-role to that user due to which sharing is calculated as a result mixed DML
will be introduced.
Question 21. What are the ways to avoid mixed DML errors?
Answer – To avoid this error we need to convert this process from synchronous to
asynchronous. The possible way is to make it a Future Method. It will separate the
transaction which help us to avoid this error.
Question 22. What is the default and maximum size of the batch?
Answer – No, we cannot call future methods from batch apex. As they operate
differently. Mixing these can lead to unexpected behaviour.
Suppose I am running a batch to update the object record. Now client wants when the
batch finishes running, they should get the mail with the count of how many records
updated successfully and how many have failed. How can we implement this scenario
//execute logic
try {
successCount++;
} catch (Exception e) {
failureCount++;
}}}
mail.setToAddresses(toAddresses);
// Send email
}}
I have an LWC component that takes multiple inputs from the user for the Account
record and has a button which when the user clicks it, calls the apex method which
handles the update. But while clicking the button user is facing below Limit Exception
below. What could be the possible reason?
At the time of using it with wire, we have to explicitly make it true because wire uses
browser cache.
Question 26. How can we able to communicate between two LWC components?
Answer – For communication in LWC we have different ways: Parent to Child, Child to
Parent, Lightning Message Service.
2. Child to Parent – To implement this we dispatch the event from the child and
catch it in the parent.
3. Lightning Message Service – Here we create the Channel and one component
will be the publisher from which we want to send the data and one will be the
subscriber who receives the data.
Suppose I have a batch running and in the start, it fetches around 1000 records of
accounts and the batch is running in 5 so each batch will take 200 records with it. In the
execute method I have a loop running over that list of accounts. I am updating the
account record in the loop. Now what could be the possible governor limit I can hit?
Answer – Here the possible limit I can hit is LimitException because we are updating in
the loop and when the scope is getting 200 records. The DML limit per transaction for
Batch is 150 so as soon as I get the 151th record in the loop I’ll get the error.
Event capturing is the opposite of Bubbling, here component will propagate downward
to the child from the Parent. It is not the default behaviour we have to explicitly make it
true.
Question 29. What are deep copy and shallow copy of objects?
Answer – Shallow copy creates the copy of an object but not for its nested properties. It
creates a reference to it. So any changes to the nested properties of a copied object will
also change to the original one. Like spread operator creates the shallow copy.
Hence you can see above the copied object and the original both get changed for the
nested object.
But for a deep copy, it is different, it creates the copy without actually referencing them
so any changes in the copied object will not affect the original one and by
JSON.stringify(JSON.parse(obj1)) we can create the deep copy of objects.
Let’s say I have a batch with a total of 1000 records to execute, and the batch size is set
to 200. This means that the processing will occur in 5 batches. If the first 4 batches are
processed successfully but encounter an error in the 5th batch due to 4-5 records, the
question is whether the entire batch is rolled back or only those 4-5 problematic
records are rolled back.
Question 31. What is the limit of total number of records retrieved by SOQL
queries?
Answer – The limit of the total number of records retrieved by SOQL queries in
Salesforce is 50,000 for both synchronous and asynchronous.
Question 32. What are the CPU time limit and Execution time limit in Salesforce?
Answer – In Salesforce CPU Time is calculated based on all the executions on the
Salesforce application servers occurring in one Apex transaction—for the executing
Apex code, and any processes that are called from this code, such as package code and
workflows. Time spent in DML, SOQL and SOSL isn’t counted.
Execution time for each Apex transaction we have is 10 minutes for both Synchronous
and Asynchronous.
Governor limits are resource utilization limits enforced on Apex by Salesforce to prevent
run away processes from monopolizing resources. This is vital as Salesforce is a multi-
tenanted environment, so run resources are shared. Examples of these are the number
of SOQL queries, DML statements, and the number HTTP callout requests in a
transaction.
The server side language used to customize Salesforce is called Apex, which has a
syntax similar to Java. On the front end, we have several technologies, the main one
being Lightning Web Components, followed by the older and now more niche Aura
Components and Visualforce – all of which use HTML, CSS, and JavaScript in
conjunction with Apex. We can also use Flow, which is a low code language to
customize both the front end and the backend.
The most basic declarative tool is custom fields and custom objects, which can be
defined declaratively and allow us to customize an instance’s database schema. We
can further customize objects through the use of page layouts, and Lightning app pages
to declaratively customize the look and feel of a record’s page.
One of the main advantages of running a coded solution is that performance will exceed
that of a declarative solution due to the ability to use more specialized logic and
removing overheads. This also applies to user interfaces as using a coded solution
allows us to fully customize it to our requirements, whereas using declarative tools
means we are stuck with what comes out-of-the-box – which may not provide the
desired outcome.
Salesforce has major updates three times a year, seasonally, in Spring, Summer and
Winter. The specific dates for these vary, however, around 4-6 weeks before a release,
sandbox instances are updated to allow for testing of any customizations in an org.
The main Salesforce supported development tool is the Salesforce Extensions for VS
Code which utilizes the Salesforce Command Line Interface.
Lookup Relationship: Two records related to each other through one object (the child)
having a lookup field which is pointing to the other (the parent).
Master-detail: Similar to a lookup relationship, however in this case the child record is
considered the detail and the parent the master. This type of relationship changes some
behaviours of the detail records, such as having sharing controlled by the master and
allowing special rollup-summary fields to be created on the master.
Self: A lookup relationship which points to the same object type, allowing a hierarchy or
chaining of records of the same type. However, a record cannot be related to itself.
8. What is SOQL?
SOQL stands for Salesforce Object Query Language, and as the name suggests it is the
main language used for performing queries against the database. While it has a similar
syntax to SQL, there are a few key differences, mainly that SOQL is exclusively used for
queries (i.e. SELECT statements).
It is used to retrieve data from a single object, and potentially those directly related to it.
SOQL can be used both within Apex code – to query records for consumption by said
code – or via the API and tools which use it – such as in data loading tools.
Apex Programming
When deploying Apex code to production, there are three things which are required:
2. Tests must cover at least 75% of all Apex code and there must not be any
failures.
10. What’s the difference between queueable Apex, batch Apex and schedulable
Apex?
Queueable Apex: This is an async process which can be launched to run processing,
callouts, etc. This is useful when trying to do processes in triggers which are long
running, or simply unavailable, e.g. callouts.
Batch Apex: An Apex process which is designed to handle large numbers of records (up
to 50 million) by processing them in smaller batches of 1 – 2000 records at a time.
Scheduled Apex: A process that is scheduled to run at a specific time and date. This
can be customized to be repeatable, either by scheduling it through the UI, or via a
CRON string within other Apex code.
11. What are the different events for an Apex Trigger?
Triggers are split into two main types: before and after.
Before triggers run before a record has been saved into the database – optimally used
for same record calculations and validations. Whereas, after triggers run after the
record has been saved, and should ideally be used for working on records other than
the one invoking the trigger.
Triggers are then further broken down into the type of operation which invokes it. These
are: insert, update, delete, and undelete. This allows the triggers to be customized to
only be invoked when explicitly required.
A global Apex class is an Apex class which has been declared with the global access
modifier. This means that the class is visible and usable by any Apex code running in any
namespace. Global Apex class should rarely be used and only implemented when
explicitly necessary, e.g. within managed packages or for Apex REST web services.
Using interfaces signifies that a class will explicitly implement the methods defined in it,
potentially allowing us to implement different behavior at run time based on context.
When Apex code runs, we can generate debug logs for the executed code. These logs
provide an insight into what happened during execution, any exceptions that were
thrown, and also provide the details of anything passed into a System.debug() method
call.
If we increase the logging levels sufficiently, we can also use the Apex Replay Debugger,
which allows us to use VS Code to step through the code execution and examine it in
more detail and set checkpoints and breakpoints for a more in-depth debugging
experience.
Integrations
For integrating with external REST web services, we would tend to use HTTP callouts to
invoke the external API. We can use the JSON and XMLStreamWriter classes to build
payloads to match the specifics of the external API.
External systems can utilize the built in REST API provided by Salesforce for simple
integrations. This could be for creating, updating, querying records. For more niche, or
bespoke, inbound integrations.
Depending on the type of credentials, we have a few options. The most preferred
is Named Credentials which specify the base endpoint and the authentication
credentials. These are preferred since Salesforce then handles the authentication for us
and keeps the credentials away from prying eyes.
Alternatively, if named credentials are not suitable, we could choose to store the
credentials in a Custom Metadata type, which will allow different credentials to be
used across different environments and we can secure the permissions to access the
metadata type. We should never be hard coding the credentials for integrations within
our code as this is very insecure.
Lightning Components
19. What is the difference between Lightning Web Components and Aura
components?
Lightning Web Components is built using current web standards to build custom HTML
elements, through the use of Web Components – designed to run in a lightweight and
performant manner. Aura components are the legacy Lightning Component framework,
but still utilize JavaScript and HTML for development.
20. Why would we use Lightning Web Components over Aura components and vice
versa?
Ideally, we should always be using Lightning Web Components for any new
developments, due to their easier development and better performance. We should
avoid using Aura components unless we wish to use a piece of functionality which is not
yet supported in LWCs, in this case we should wrap an LWC inside of an Aura
component.
Read more:
• Flows
• Visualforce pages
• Pre-chat snap-ins
• Quick Actions
The Salesforce Lightning Design System (SLDS) is the user interface design framework
used by Salesforce for designing, styling, and building all aspects of Salesforce
Lightning.
As developers, we can utilize the SLDS provided CSS styles or component markup
templates to build custom components which provide a consistent UI with the rest of
the platform. SLDS also provides guidelines around accessibility, language guidance,
and icons.
Secure Development
24. How can we enforce Field Level Security (FLS) within our Apex code?
There are a few approaches depending on the context of where we wish to enforce Field
Level Security.
If we need more granularity or wish to simply remove fields a user does not have
sufficient permissions for, we can use the Security.stripInaccessible() method. As the
name suggests this method checks for, and removes any field values for, the specific
context requested, e.g. removing fields which the user does not have permissions to
update.
25. How can we enforce Sharing Rules within our Apex code?
We can define our class to use the with sharing keywords in its definition. Alternatively
we can use the inherited sharing keywords, which inherits the sharing modifier from its
calling class for when we need code that should handle this dynamically.
26. When should we bypass sharing and FLS within our code?
We should only bypass these when we are running system level processes. If we do
need to bypass them for user operations, we should be ensuring there is no chance data
or actions which are unintended can be performed.
This could be by migrating the specific actions which require bypassing to separate
classes and performing the rest of our logic with sharing and FLS enforced. We should
only ever be bypassing it for specific actions, not an entire set of business logic.
When we are performing dynamic SOQL which takes an input from a user, we must
sanitize the user input. We do this by making sure all single quotes are escaped before
performing the query. Alternatively, wherever possible, we want to use bind variables,
even with our dynamic SOQL.
Configurable Development
Roll-up summary fields are special fields which lie on the master side of a master-detail
relationship. These fields have their values calculated based on an aggregate of the
detail side of the relationship – this could be anything from the number of records to a
field value summed up. It allows us to skip using Apex when we wish to aggregate
record values that are part of a master-detail relationship.
29. What are Custom Metadata Types and why would we use them?
Custom Metadata Types are developer designed pieces of metadata which facilitate the
designing and building of customizable applications within a Salesforce instance. This
is done by first designing the metadata type, which is similar to a custom object, and
then by creating records of that type to define the required behavior, by being read at run
time. This could be anything from defining a field mappings table between two objects,
to storing secrets for an API integration.
2. What are some common Salesforce products you are familiar with?
Answer: I am familiar with Sales Cloud, Service Cloud, Marketing Cloud, and Salesforce
Commerce Cloud. Each serves different aspects of CRM, from sales and customer
service to marketing and e-commerce.
Answer: Apex is a proprietary programming language by Salesforce. It’s used for writing
server-side logic and custom business processes in the Salesforce environment.
Answer: I used Visualforce to create a custom user interface for a specific client need. It
involved customizing a page layout and integrating it with Apex controllers for specific
functionalities.
Answer: Apex has governor limits to ensure shared resources are used efficiently, like
limits on memory usage, number of records processed, and API callouts in a single
transaction.
Answer: A trigger in Salesforce is a piece of Apex code that executes before or after data
manipulation operations like insert, update, or delete. It’s used to perform custom
actions automatically.
Answer: Ensuring code quality involves writing clean, efficient Apex code, following best
practices, conducting peer reviews, and performing unit testing to cover various
scenarios.
Answer: A Sandbox in Salesforce is a copy of the production environment. It’s used for
development, testing, and training without affecting the live environment.
Answer: A workflow rule automates certain processes based on specific criteria. For
example, it can automatically send an email alert, create tasks, or update fields when a
record meets certain conditions.
Answer: Debugging in Salesforce involves using the Developer Console and debug logs
to trace and resolve issues. System.debug statements in Apex help in tracking variable
values and process flows.
Answer: Batch Apex is used to process large numbers of records asynchronously. It’s
useful when operations can’t be processed in a single transaction due to governor
limits.
Answer: I used Lightning Components to build reusable and dynamic user interfaces in
Salesforce. This involved creating both Aura and Web Components, depending on the
project requirement.
19. What strategies do you use for effective time management in project
delivery?
Answer: I prioritize tasks based on urgency and importance, break down large tasks into
manageable chunks, and use tools like calendars and to-do lists for better organization.
2. Can you explain the concept of Governor Limits and how you manage them?
Answer: Governor Limits are Salesforce’s way of ensuring resource allocation fairness. I
manage them by optimizing code, using bulkified operations, and efficient SOQL
queries.
Answer: Data security is ensured through proper profile and permission set
configurations, field-level security, and using sharing rules and roles to control record
access.
Answer: Change sets are used for deploying components from one Salesforce org to
another. They are particularly useful for transferring customizations in a controlled and
traceable manner.
Answer: I wrote a complex trigger that handled multiple related objects, ensuring data
integrity across them. It involved careful bulkification and error handling to comply with
governor limits and robust functionality.
Answer: I’ve used Visualforce for creating bespoke user interfaces, integrating with Apex
controllers for advanced functionalities, and ensuring they are responsive and efficient.
Answer: I’ve integrated Salesforce with external systems using REST and SOAP APIs.
This involved understanding external systems, mapping data, and handling
authentication and error scenarios.
9. What are your strategies for managing large data volumes in Salesforce?
Answer: Managing large data volumes involves using proper indexing, archiving old
records, optimizing page layouts, and using efficient query filters.
10. How do you keep abreast of new Salesforce features and updates?
Answer: I regularly check Salesforce release notes, participate in developer forums, and
engage in continuous learning through Trailhead and other online resources.
Answer: Lightning Web Components (LWC) are a modern framework for building fast,
efficient, and reusable UI components. They leverage web standards and improve
performance and user experience.
Answer: I troubleshooted a complex issue involving asynchronous Apex and batch job
conflicts. It required in-depth analysis of the execution logs and understanding the
interdependencies within the system.
Answer: I use a combination of change sets and version control systems like Git. I follow
best practices for deployment, including thorough testing in a staging environment
before production deployment.
15. What experience do you have with Salesforce mobile app customization?
Answer: I have customized Salesforce mobile apps using the Salesforce Mobile SDK,
optimizing layouts for mobile and ensuring consistent user experience across devices.
16. How would you handle a request for a feature that’s not natively supported
by Salesforce?
Answer: I would first explore AppExchange for suitable add-ons. If unavailable, I’d
assess the feasibility of custom development using Apex or LWC, always considering
maintenance and scalability.
Answer: Good documentation is crucial. I document both the technical aspects and
user guides, ensuring they are clear, concise, and updated regularly.
Answer: I have created complex reports and dashboards, utilizing features like report
formulas, joined reports, and dynamic dashboards to provide actionable insights.
Answer: For complex integrations, I analyze the external systems, design robust
integration patterns using REST/SOAP APIs or middleware, and ensure data consistency
and error handling are meticulously addressed.
Answer: I enforce coding standards, conduct regular code reviews, and advocate for
comprehensive unit testing. Additionally, I encourage knowledge sharing sessions to
maintain high code quality across the team.
8. What’s your strategy for keeping up with the frequent updates and changes
in the Salesforce ecosystem?
10. Explain how you manage user adoption for new Salesforce features or
systems.
13. Discuss how you have used Einstein Analytics in your projects.
Answer: In my projects, I have utilized Einstein Analytics for advanced data analysis,
creating predictive models, and delivering customized dashboards to provide deeper
insights into business performance.
Answer: My approach involves thorough analysis of the issue, replicating the problem in
a test environment, implementing a fix, and conducting rigorous testing before
deploying the solution to production.
Answer: I have automated business processes using Workflow Rules, Process Builder,
and Flow, optimizing operations, reducing manual work, and enhancing overall
efficiency.
16. How do you balance the use of declarative vs. programmatic capabilities in
Salesforce?
Answer: I balance these by using declarative tools for simpler requirements and reserve
programmatic solutions for complex scenarios, ensuring the system remains flexible
and maintainable.
17. Describe a time you had to make a critical decision in a Salesforce project.
Answer: I made a critical decision in a project where we had to choose between custom
development and an off-the-shelf AppExchange product. It involved analyzing cost,
scalability, and long-term maintenance.
Answer: Data migration and cleansing involve planning the data mapping, using tools
like Data Loader for migration, and implementing scripts or tools for cleansing and
deduplication.
Answer: I have developed Salesforce mobile applications using Salesforce Mobile SDK,
focusing on user experience, performance, and offline capabilities.
Answer: I would perform a thorough analysis to identify the specific limits being hit,
optimize the code by reducing SOQL queries, using bulkified patterns, and
implementing more efficient data handling practices.
3. Scenario: The sales team needs a custom Salesforce mobile app. How do
you proceed?
Answer: I’d start by gathering detailed requirements from the sales team, then design a
user-friendly interface focusing on their key needs, and use Salesforce Mobile SDK to
develop and deploy the app.
4. Scenario: Users report that a specific Salesforce process is too slow. What
steps do you take?
Answer: I’d first replicate the issue in a test environment, analyze the process for
inefficiencies, possibly optimize workflow rules or process builder flows, and ensure
that any Apex code is bulkified and efficient.
5. Scenario: You need to migrate a large amount of data into Salesforce. How
do you ensure data integrity?
Answer: I would use a reliable ETL tool, thoroughly map data fields, perform data
cleansing before migration, and conduct extensive testing post-migration to ensure data
integrity.
Answer: My strategy involves training the team on Lightning, conducting an audit of our
existing setup, prioritizing components for migration, and implementing changes in
phases to ensure a smooth transition.
10. Scenario: You discover a security flaw in your Salesforce setup. What
actions do you take?
Answer: Immediately, I’d assess the scope of the flaw, implement a fix or workaround,
and conduct a security audit to prevent similar issues. I’d also review and update
security best practices with the team.
Answer: I choose based on the complexity and needs of the process – Flow for complex
logic, Process Builder for straightforward automation, and Apex for scenarios needing
advanced coding.
12. Scenario: You’re asked to improve the Salesforce UX for a better customer
experience. What’s your plan?
14. Scenario: You need to ensure high data quality in Salesforce. What steps do
you take?
Answer: I’d implement validation rules, duplicate rules, and regular data audits.
Additionally, I’d train users on data entry best practices and use automation to assist in
maintaining data quality.
16. Scenario: A critical update is required in the Salesforce system during peak
business hours. How do you handle it?
Answer: I’d plan the update meticulously to minimize disruption, communicate clearly
with stakeholders about the timing, and ensure a rollback plan is in place in case of
unforeseen issues.
17. Scenario: You are asked to reduce the Salesforce licensing costs for your
company. What approach do you take?
Answer: I’d conduct a thorough audit of current license usage, identify underutilized
licenses or features, and strategize on optimizing license allocation without impacting
business operations.
18. Scenario: You’re tasked with enhancing the Salesforce mobile experience
for remote sales teams. What are your key focus areas?
Answer: My focus areas would be on optimizing the mobile UI for ease of use, ensuring
offline capabilities, and integrating essential features that cater to the unique needs of
remote sales teams.
19. Scenario: The organization requires a custom report generation tool within
Salesforce. What’s your strategy?
Answer: I’d evaluate the specific reporting needs, develop custom reports or
dashboards using SOQL and Apex if needed, and ensure they are user-friendly and
provide actionable insights.
Answer: Governor Limits are Salesforce’s way of enforcing limits on the usage of
resources like memory, SOQL queries, DML statements, etc., to ensure that no single
process or code monopolizes shared resources.
Answer: In Apex, upsert operations are performed using the upsert statement. It creates
new records and updates existing ones based on the specified key field.
Answer: Triggers in Salesforce are used to perform custom actions before or after
changes to Salesforce records, such as updates, inserts, or deletions. They’re written in
Apex and can be used to automate complex business logic.
Answer: A custom controller is an Apex class that implements all the logic for a page
without leveraging the standard controller provided by Salesforce, giving developers
complete control over the behavior of a Visualforce page.
Answer: Test classes in Salesforce are used to ensure that Apex classes and triggers
work as expected. They are necessary for deploying code to production and are crucial
for maintaining code quality and integrity.
Answer: Exceptions in Apex are handled using try, catch, and finally blocks. You can
write code to gracefully handle exceptions and ensure that the user gets meaningful
error messages.
8. What are batch Apex classes and where are they used?
Answer: Batch Apex classes are used for processing large data sets that exceed normal
processing limits. They allow you to define a job that can be divided into manageable
chunks, processed separately, and executed in a serial manner.
Answer: Visualforce pages are used when a custom user interface is needed that can’t
be achieved with Salesforce’s standard UI. For example, creating a complex form that
includes custom logic or styling.
Answer: The @future annotation in Apex is used for executing methods asynchronously.
It’s useful for running processes in a separate thread, especially when you are dealing
with callouts to external services.
Answer: To protect against SOQL injection, it’s important to avoid dynamic SOQL
queries when possible. If dynamic queries are necessary, use binding variables instead
of string concatenation to create the query.
Answer: In Apex, there are three types of collections: Lists (ordered, indexable
collections), Sets (unordered collections of unique elements), and Maps (collections of
key-value pairs).
Answer: Error handling in batch Apex can be implemented using try-catch blocks within
the execute method, and by overriding the finish method to handle post-processing and
notification of the batch job status.
Answer: Schema Builder provides a dynamic environment to add new objects, fields,
and relationships to your schema. It is a powerful tool for designing and modifying your
data model visually.
Answer: Custom web services in Salesforce are created using Apex. You define a global
class with the webservice keyword, write methods to expose as web service operations,
and then deploy the service for external access.
16. How can you call an external REST service from Apex?
Answer: To call an external REST service from Apex, you use the HttpRequest and
HttpResponse classes. You set up the request URL, headers, method (GET, POST, etc.),
and then send the request using the Http class.
Answer: The with sharing keyword is used in Apex classes to enforce the sharing rules
that apply to the current user. This ensures that users can only access records that
they’re permitted to access based on the organization’s sharing policies.
Answer: Apex code can be debugged using the Developer Console or debugging tools
available in the Salesforce IDE. Debug logs can be generated to track the execution of
code, monitor variables, and observe system processes.
Answer: A wrapper class in Apex is a custom class defined by the developer that wraps
around standard or custom objects. It’s often used to combine data from different
objects or add additional attributes for use in Visualforce pages.
Answer: To ensure an Apex class is deployable to production, it must have at least 75%
code coverage from unit tests, and all those tests must pass without errors.
Additionally, the code should adhere to Salesforce best practices for maintainability
and efficiency.
o Use Process Builder and Flow: For automating business logic, use
Process Builder or Flow rather than triggers, as they provide declarative
solutions and are easier to maintain.
o Bulkify Your Code: Always ensure that your Apex code is bulkified. Avoid
SOQL queries or DML operations inside loops.
o Test Coverage: Ensure that all Apex code is unit tested with at least 75%
code coverage. Tests should be robust and cover different edge cases.
o Keep SOQL Queries Outside Loops: Always avoid querying data inside a
loop to prevent hitting governor limits.
• Objects in Salesforce are database tables that store data. There are two types:
• Relationships define how objects are related to each other. Salesforce supports
different relationship types:
• Lookup Relationship:
o One object "looks up" to another but the related record can exist
independently.
• Master-Detail Relationship:
o The detail record is tightly dependent on the master record. The child
(detail) record cannot exist without the master.
o If the master record is deleted, all related child records are also deleted
(cascade delete).
o The child record inherits ownership and security settings from the master.
Example: An opportunity can be linked to multiple contacts, and each contact can be
linked to multiple opportunities. To represent this relationship, you would create a
junction object like "Opportunity Contact Role" that links opportunities and contacts.
• Roles: Define the hierarchy of users in the organization. A user's role determines
their visibility to data based on the role hierarchy. Higher roles can see records
owned by lower roles.
Salesforce enforces governor limits to ensure efficient use of resources and maintain
the performance of its multi-tenant architecture. Some important governor limits
include:
• Apex CPU Time: Maximum execution time for Apex code (10,000 ms per
transaction).
• Heap Size: Maximum memory allowed for Apex variables (6 MB for synchronous
operations, 12 MB for asynchronous operations).
It’s important to write optimized and bulkified code to avoid hitting these limits.
1.7 What's the Most and the Least Restricted Salesforce Security Models?
• Most Restricted:
o Sharing Rules: The Private sharing model is the most restrictive. Each
record is only visible to the record owner and users above them in the role
hierarchy.
• Least Restricted:
o Public Read/Write: The Public sharing model allows all users to see and
modify all records. This is the least restrictive model.
1.8 How Many Junction Objects Can You Have on One Object?
There’s no hard limit on the number of junction objects you can create for a single
object, but you are limited by the maximum number of relationships a single object can
have. Salesforce allows up to 40 total relationships per object, including lookup and
master-detail relationships.
For many-to-many relationships, this means you can create multiple junction objects,
but the total number of relationships per object (including these junctions) cannot
exceed the limit of 40.
1.9 How Would You Code Error Tracking in Your Application, So That Your End Users
Can Access This Information?
1. Create a Custom Error Object: You can create a custom object called
Error_Log__c to store error details, such as error type, message, user, timestamp,
and affected records.
2. Log Errors in Apex: In your Apex code, use try-catch blocks to capture
exceptions and then create new records in the Error_Log__c object with the
relevant error details.
apex
CopyEdit
try {
} catch (Exception e) {
Error_Message__c = e.getMessage(),
Stack_Trace__c = e.getStackTraceString(),
User__c = UserInfo.getUserId(),
Record_Id__c = yourRecordId
);
insert errorLog;
5. Use Debug Logs: For internal troubleshooting, Salesforce Debug Logs can be
used to capture detailed logs for developers when tracking complex issues in
production.
By combining the above strategies, you can create an effective error tracking system
that is both developer-friendly and user-accessible.
Org-Wide Default (OWD) defines the baseline level of access to records for all users in
an organization. It determines how records are shared by default across the entire
Salesforce org. OWD settings are the foundation for setting up sharing rules and
permissions.
• Private: Only the record owner and users above them in the role hierarchy can
view and edit the record.
• Public Read Only: All users can view the record, but only the owner and users
above them in the role hierarchy can edit it.
• Public Read/Write: All users can view and edit the record.
By setting OWD, you can control who has access to the records and build further
sharing strategies on top of this baseline.
2.2 Sharing Rules vs. Manual Sharing Rules: When and Why Would You Use Them?
• Sharing Rules:
o Types: You can create sharing rules based on role hierarchy, public
groups, or territory.
o When to Use: Use sharing rules when you need to grant broader access
to specific records based on criteria such as record owner or other field
values.
Key Difference: Sharing rules are automatic and apply to groups of records, while
manual sharing is more granular and applies to individual records.
Salesforce Shield is a suite of advanced security tools designed to help you secure
your Salesforce data and ensure compliance with regulatory standards. It includes the
following features:
• Field Audit Trail: Allows you to track the history of changes to fields for up to 10
years.
• Event Monitoring: Tracks and logs user activities across the Salesforce platform,
allowing admins to monitor how users interact with data and applications.
Salesforce Shield is useful for industries and organizations that need enhanced data
security and compliance capabilities, such as in healthcare, financial services, or
government.
Custom Settings are a type of custom object that provide a way to store application
configuration data that can be accessed in Apex code or formulas. There are two types
of custom settings:
• List Custom Settings: Store data that is accessible by all users in the org.
3. Provide a Name and Object Name for the custom setting (e.g., API_Config__c).
Example: If you want to store API configuration values, you would create a custom
setting to store keys, endpoint URLs, etc., and reference those values in Apex code.
apex
CopyEdit
2.5 What’s the Difference Between Scheduled Jobs and Apex Jobs?
• Scheduled Jobs:
o Purpose: Scheduled jobs are used to run Apex code at specified times or
intervals (e.g., daily, weekly).
o Use Case: Ideal for automation that needs to run on a regular schedule
without user intervention, such as batch data processing or sending
regular reports.
Example:
apex
CopyEdit
o Use Case: Useful for operations that can be executed in the background
without blocking user interaction, such as sending bulk emails or
performing calculations on large datasets.
To whitelist a website in Salesforce, you typically use Remote Site Settings. These
settings define which external URLs are allowed to be accessed from Salesforce.
To whitelist a website:
1. Go to Setup.
4. Provide a Name and the URL of the site you want to whitelist.
2.7 What is a Platform Event and How Would You Create One?
1. Go to Setup.
apex
CopyEdit
Debug Logs help developers trace issues by providing detailed logs about what
happens when a process runs in Salesforce, including user interactions, data changes,
and system operations.
1. Go to Setup.
4. Choose the user whose actions you want to log (usually yourself or a user
experiencing an issue).
You can view the logs by navigating to the Debug Logs page and clicking on the log
entries.
1. Go to Setup.
5. Enable OAuth settings and define the OAuth scopes (permissions) for the app.
The connected app generates credentials (Client ID and Client Secret) that are used to
authenticate external applications via OAuth 2.0.
To make an Apex class available to a specific profile, you need to modify the Profile
Settings:
1. Go to Setup.
2. In the Quick Find box, type Profiles and select the profile you want to modify.
4. Click Edit.
5. Select the Apex class you want to make available from the list of available
classes.
This allows only users with the specified profile to access and execute the Apex class.
In Salesforce, you can use several declarative tools to send emails, but the most
common ones are:
• Process Builder: You can use Process Builder to send emails as part of an
automated workflow when certain criteria are met.
o Steps:
2. Define the criteria for the process (e.g., when a record is created or
updated).
o Steps:
• Email Alerts: Email Alerts can be set up within Workflow Rules or Process
Builder to trigger emails when certain conditions are met.
1. Screen Flow:
4. Scheduled Flow:
o Used for flows that need to run at scheduled times. Ideal for batch
operations or periodic tasks like sending out reports or updating records
daily.
Both Validation Rules and Flows can be used to ensure data consistency and enforce
business rules in Salesforce. Here are their similarities:
• Data Integrity: Both can enforce business logic to ensure that only valid data is
entered into Salesforce.
• Error Messages: Both can display error messages when the validation or logic
fails.
o Flow: Can show a screen or use a Fault path to display an error message
or handle the issue.
• User Interaction: Validation Rules are typically triggered when saving a record,
while Flows can be used to guide users through a process and prompt for
corrections or inputs.
Key Differences:
• Validation Rules are simpler and focus on data validation. Flows are more
complex and provide greater flexibility for automation, data manipulation, and
user interaction.
3.4 Where Would You Use Custom Metadata Types, Custom Settings, and Labels?
Code Snippet:
apex
CopyEdit
System.debug(config.My_Field__c);
• Custom Settings:
o Used for storing application-specific data, similar to Custom Metadata,
but they can be used to store user or profile-specific data as well.
• Custom Labels:
o Example Use: Defining error messages that will be shown to users based
on different contexts.
Example Use:
apex
CopyEdit
In Salesforce Flows, errors can be handled using Fault Paths and Decision Elements:
1. Fault Path:
o Every Flow element can have a Fault path, which is triggered if an error
occurs while executing that element.
2. Decision Elements:
o You can use Decision elements to check for specific conditions and
handle errors by providing alternative paths (e.g., showing an error
message if a required field is not filled).
Example:
• Add a Fault Path to a record update element. If an error occurs, navigate the
user to a screen that explains the problem.
3.6 What's the Difference Between Scheduled Flow and Scheduled Apex?
• Scheduled Flow:
o A Scheduled Flow runs at a specified time, like once a day, and it is ideal
for tasks such as batch processing, record updates, and email reminders.
It’s easier to set up and doesn’t require Apex code.
• Scheduled Apex:
apex
CopyEdit
acc.Status__c = 'Inactive';
update accountsToUpdate;
// To schedule it
3.7 What Is There You CAN and CAN'T Do in Declarative Development and Apex?
• User Interface: Customize page layouts, create record types, add validation
rules, and create dynamic actions.
• Bulk Data Processing: When dealing with large amounts of data or complex
data manipulations, declarative tools may run into governor limits.
• Complex Logic: Apex allows for complex business logic, handling advanced
calculations and processes that can't be achieved through declarative tools.
• Bulk Data Processing: Apex can handle large data volumes and batch
processing (via Batch Apex or Queueable Apex).
• Custom UI Components: You can build custom Visualforce pages and Lightning
Web Components (LWC) for advanced UI needs.
In summary:
• Declarative tools are great for simple to moderately complex tasks, quick
implementations, and non-technical users.
• Apex is better suited for handling complex logic, large data volumes, and
advanced integrations but requires coding and deeper technical knowledge.
4.1 What is Trigger-Based Framework? What are Before and After Triggers?
• Before Triggers: These are executed before a record is saved to the database.
o Use Case: Before triggers are typically used for validation, setting default
field values, or preventing updates.
• After Triggers: These are executed after a record is saved to the database. You
can’t modify the record’s fields in after triggers (since the record is already
committed to the database).
o Use Case: After triggers are useful for performing actions like sending
emails, creating related records, or updating external systems.
Code Example:
apex
CopyEdit
Salesforce allows only one trigger per object. However, you can have multiple trigger
events (e.g., before insert, after update, etc.) within a single trigger. It's best practice to
handle all events (insert, update, delete, undelete) in one trigger rather than creating
separate triggers.
Best Practice:
• Ensure the trigger follows the "one trigger per object" rule and calls a handler
class to keep it clean.
Example:
apex
CopyEdit
trigger AccountTrigger on Account (before insert, after insert, before update, after
update) {
if(Trigger.isBefore) {
} else if(Trigger.isAfter) {
}
4.3 How Do You Restrict Field Access in Apex?
You can restrict field-level access in Apex using the SObjectField class to check if the
current user has access to a specific field. This helps ensure that users do not interact
with fields they don’t have access to, based on their profile or permissions.
Example:
apex
CopyEdit
if(Schema.sObjectType.Account.fields.Name.isAccessible()) {
You can also use isUpdateable() or isCreateable() for other field-level access checks.
Asynchronous Apex is used when you need to run a long-running operation that
doesn’t need to complete immediately. It allows Salesforce to process data in the
background without blocking the user experience.
1. Future Methods: Used for operations that should run in the background,
like making callouts or processing data.
• Future Methods:
o Use Case: Best for simple asynchronous operations that don’t require
complex logic.
o Limitations: Cannot be chained, can only return void, and have fewer
limitations on data types.
apex
CopyEdit
@future
update acc;
• Queueable Apex:
o Use Case: More powerful than future methods, allowing for complex
logic, better error handling, and the ability to chain jobs.
apex
CopyEdit
update accounts;
Invokable Apex refers to Apex methods that are exposed to be called by Flows,
Process Builder, and other declarative tools. These methods are annotated with
@InvocableMethod to make them callable by these tools.
Use Case: You can create reusable logic that is called from a Flow without needing to
write Flow-specific logic.
Example:
apex
CopyEdit
update accounts;
o Example:
apex
CopyEdit
List<Account> accounts = [SELECT Id, Name FROM Account WHERE Name = 'Acme'];
apex
CopyEdit
Key Difference: SOQL is used for querying a specific object or related records, while
SOSL is used for searching across multiple objects or fields.
Salesforce Web Services allow for integration between Salesforce and external systems
via SOAP (Simple Object Access Protocol) or REST (Representational State Transfer)
APIs. These web services enable you to expose or consume data from Salesforce to
external applications or other Salesforce orgs.
• SOAP API: A robust API that supports complex data and is typically used for
enterprise-level integrations.
• REST API: A simpler, more lightweight API that is often used for mobile or web
applications.
2. ANT Migration Tool: A command-line tool that allows for deploying and
retrieving metadata.
3. Salesforce CLI: Allows you to deploy code using scripts in a more flexible
manner, using commands like sfdx force:source:deploy.
4. IDE Tools (like Visual Studio Code): You can use the Salesforce Extensions for
VS Code to deploy code to Salesforce.
4.10 How Much Test Coverage Do You Have in Your Test Classes?
Salesforce requires at least 75% test coverage of your Apex code to deploy it to a
production environment. However, it’s best practice to aim for 100% coverage to
ensure that all scenarios and edge cases are tested.
Best Practice:
• Write test classes to cover both positive and negative test cases.
4.11 Talk About the Difference Between LC, Aura, Visualforce, and LWC
• Aura: A framework that allows you to build dynamic web apps for mobile and
desktop. It was the predecessor to LWC and is still in use but is less preferred for
new development.
• LWC (Lightning Web Components): The modern framework for building fast,
reusable components using standard web technologies like JavaScript, HTML,
and CSS.
Key Difference:
• Aura and LC are older frameworks with a more complex architecture, while LWC
leverages modern web standards and provides a simpler, faster approach.
Sharing rules in Apex refer to using the Share object to programmatically grant record
access to users. For example, you can write Apex code to share records of a custom
object with specific users or groups.
Example:
apex
CopyEdit
accShare.ParentId = accountId;
accShare.UserOrGroupId = userId;
accShare.AccessLevel = 'Read';
insert accShare;
Example: Create a Named Credential for an external system and then use
NamedCredential in Apex to make secure callouts.
Example:
apex
CopyEdit
System.debug('Doing something');
Yes, Apex methods can have multiple decorators, but certain decorators can’t be
combined. For instance:
Lightning Out allows you to run Lightning components outside of Salesforce, such as in
an external website or application, using a browser’s JavaScript environment.
System.runAs() is used in test classes to simulate running code as a specific user. This
is useful when you need to test the behavior of your Apex code under different user
profiles or permission sets.
To seed custom metadata in a test class, you can create a new record of the custom
metadata type in the test method.
Example:
apex
CopyEdit
@isTest
@isTest
MasterLabel = 'TestConfig',
MyField__c = 'TestValue'
);
insert newMetadata;
It's essential that test classes contain assertions to verify the expected outcomes. Aim
for 100% coverage with assertions, as they validate that your code is working correctly.
SOQL injection occurs when malicious input is directly inserted into a SOQL query,
potentially exposing sensitive data. To prevent it, always use bind variables and avoid
concatenating strings directly into SOQL queries.
Example:
apex
CopyEdit
No, formula fields cannot be encrypted directly. You can, however, encrypt data stored
in other fields and use it in formula fields.
2. Inheritance: A class can inherit properties and methods from another class,
promoting reuse.
4.25 What is the Sequence of Events in an Apex Trigger After Updating a Database?
4.26 Where Would You Use Visualforce These Days? Can You Come Up with a Use
Case?
While LWC and Aura are preferred, Visualforce is still used for legacy applications or
custom UIs that require intricate designs that LWC or Aura cannot accommodate.
Use Case: A legacy app where the UI needs extensive customizations with complex
page layouts.
4.27 Have You Worked With Managed Packages? What is Managed Package?
A Managed Package is a packaged, reusable unit of code and metadata that can be
installed into Salesforce orgs. It is typically used for distributing Salesforce apps or
solutions.
Triggers handle the data logic, while Apex classes implement business logic and
reusable components. Having both allows for a clean, organized structure.
Yes, you can test API callouts by using Mock callouts in test classes with the
Test.startTest() and Test.stopTest() methods, using HttpCalloutMock to simulate
responses.
To make an LWC available in a Flow, use the Lightning Flow Component. In the LWC
component, use the @api decorator to expose properties and methods.
Example:
javascript
CopyEdit
import { api, LightningElement } from 'lwc';
@api recordId;
• @track: Marks a property as reactive, meaning any changes to that property will
trigger the reactivity system and update the DOM accordingly. (Note: In LWC, this
is mostly implicit, and you don't need to explicitly use @track in many cases
unless the data is an object or array.)
• @wire: Used to get data from Salesforce and makes the property or method
reactive, meaning it updates when the data changes.
Example:
javascript
CopyEdit
Yes, a Lightning Web Component (LWC) can have multiple decorators on different
properties or methods. For example, you can use @api, @track, @wire on different
fields in the same component.
Example:
javascript
CopyEdit
Yes, you can declare constants outside of a class in JavaScript, including in LWC, but
these constants will be scoped to the file and will not be part of the component's class.
Example:
javascript
CopyEdit
connectedCallback() {
console.log(API_URL);
However, it's more common to define constants inside the class scope if the constant is
related to the component's state or functionality.
The $ symbol in LWC is used to reactively bind parameters when passing dynamic
properties to a @wire method. It tells the framework to observe changes to the property
and re-fetch data when the value changes.
For example, in the following code, $recordId will trigger the @wire method to re-run
whenever the recordId changes:
Example:
javascript
CopyEdit
In this example, the $ is used to make recordId reactive. Any change in the recordId will
automatically trigger the wire service to re-fetch data.
5.5 What are the Different Lifecycle Hooks in LWC?
Lifecycle hooks in LWC are methods that are automatically called at specific points in
the component's life cycle. They allow developers to run custom logic at key moments,
such as component initialization or data updates.
o Use it when you need to manipulate the DOM or perform actions that
require access to the component's rendered elements.
5. errorCallback(): Called when an error occurs during the rendering process of the
component or during the component lifecycle.
Example:
javascript
CopyEdit
connectedCallback() {
renderedCallback() {
disconnectedCallback() {
The renderedCallback() lifecycle hook is called after the component's DOM has been
rendered, and every time the component's reactive data changes (i.e., when properties
tracked with @track or @api are modified).
This is useful when you need to interact with the DOM directly (e.g., calling third-party
libraries that need to access elements after they have been rendered).
Example:
javascript
CopyEdit
renderedCallback() {
// This is called after the component has rendered and the DOM is available.
Both stopPropagation() and preventDefault() are methods on the Event object, but they
serve different purposes:
javascript
CopyEdit
handleClick(event) {
You can extend a Lightning Web Component (LWC) if you want to reuse functionality or
make a custom component more general-purpose. You can create a base class with
shared logic, and then extend it to build specific functionality in your child components.
However, in LWC, direct inheritance of one component from another is not supported
like in Aura components. But you can extend from JavaScript base classes to share
logic.
Example:
javascript
CopyEdit
// Base class
sharedMethod() {
console.log('Shared logic');
5.9 Can a LWC Component Raise and Capture the Same Event?
Yes, a Lightning Web Component (LWC) can raise and capture the same event. The
component can listen for an event, trigger it using the dispatchEvent() method, and also
handle it in the same component if necessary. Typically, events are captured by a parent
component, but you can use CustomEvent to allow both raising and handling events in
the same component.
Example:
javascript
CopyEdit
handleClick() {
// Raise an event
this.dispatchEvent(event);
connectedCallback() {
this.addEventListener('myevent', this.handleEvent);
handleEvent(event) {
}
5.10 What is the Difference Between var, let, and const?
These are three different ways to declare variables in JavaScript, with distinct behaviors
regarding scope and mutability:
Example:
javascript
CopyEdit
var a = 1;
if (true) {
console.log(a); // Outputs 2
• let: Block-scoped and allows re-assignment but not redeclaration within the
same block.
Example:
javascript
CopyEdit
let a = 1;
if (true) {
console.log(a); // Outputs 2
console.log(a); // Outputs 1
Example:
javascript
CopyEdit
const a = 1;
Communication between a parent and child Lightning Web Component (LWC) is done
using properties and events:
1. Parent to Child: The parent can pass data to the child using public properties
marked with @api.
2. Child to Parent: The child can communicate with the parent using Custom
Events.
html
CopyEdit
javascript
CopyEdit
// Child Component
this.dispatchEvent(event);
html
CopyEdit
javascript
CopyEdit
// Parent Component JS
handleMessage(event) {