SalesForce Interview Questions
SalesForce Interview Questions
SalesForce Interview Questions
3. Lightning App It offers a fast, easy way of app building and customizations with the
Builder and help of drag-and-drop features. Customization of Lightning
Community Experience is done by using Lightning App Builder for a Salesforce 1
Builder mobile app. On the other hand community builder helps in
customizations of template-based communities.
4. Lightning Design LDS makes it possible to build apps matching the looks of the
System (LDS) Salesforce 1 mobile app and Lightning experience. It has modern UX
best practices and style guides.
3 Helper The developer can write the common logic inside helper used by
different controller methods, avoiding any sort of repetition
7 SVG This icon in the Lightning App Builder gets displayed before the
component.
1
2
8 Design It not only helps in component reusability but also controls which all
attributes need to exposed for the tools like Lightning App Builder.
Q #5) How does Salesforce 1 Mobile app use Lightning components?
Answer: We first create a Lightning tab for the Lightning component and subsequently include the
tab in the navigation select list of Salesforce 1 mobile app and then the newly created tab to it.
Q #6) Can a Lightning component be used that works with both interfaces – Mobile and
Desktop?
Answer: It is possible to use Lightning components, Salesforce 1 mobile app, custom standalone
apps directly in Lightning Experience as well as template-based communities. Lightning components
are used in the Visualforce page, for use in Salesforce Visualforce communities as well as the classic
environment.
Q #7) Does Lightning Component work with Visualforce?
Answer: Yes, it does work with Visualforce.
Q #8) Can Lightning be viewed as an MVC framework?
Answer: Not really. Lightning is a framework based on components.
Q #9) Which Lightning components parts are server-side and which ones are client-side?
Answer: For the Lightning component, the client-side is the component page acting as a JavaScript
controller, on the contrary, the server-side acts as an Apex Controller.
Q #10) What are the differences between Lightning and Visualforce components?
Answer: Visualforce components are page-centric and work is mostly server-based. Lightning
components, on the other hand, are client-side centric which accounts for their dynamic, mobile-
friendly nature.
Q #11) How to add Aura components to your Visualforce page?
Answer: The developer can add the Aura components to the Visualforce page in the following
three ways:
Use the <apex:includeLightning/> component and add the Lightning component for
the Visualforce JavaScript library used in your Visualforce page.
Create a reference to a Lightning app for declaring component dependencies.
Use the $Lightning.createComponent() to create the component for a page by
writing a JavaScript function
Q #12) Can we create one component for inheriting style/CSS from the parent or we need to
always define it in the Salesforce component?
Answer: Of course, we can do this. The styles can be inherited from parents and not necessarily
defined in the component.
Q #13) What is the purpose of using Aura: method Tag in Lightning?
Answer: The Aura: method tag can be used for defining a method for component API. So, there is
no need to fire and handle a component event, and it allows us to directly invoke the method in the
component’s controller on the client-side. It also helps to simplify the code required for a parent
component to call a method on a child component that forms a part of the parent component.
Q #14) Is it possible to include a Lightning component into another?
Answer: Yes, it is possible.
Q #15) What are the limits to the number of components used in an application?
Answer: There are no limits on the usage number of the components used in an application.
Q #16) What are Aura Components? Why we use Aura: Namespace in the code?
Answer: Aura components are the self-contained and reusable units of an app. Components form the
function units of Aura. Aura is the open-source technology that works for Lightning components.
The building blocks for the Aura: namespace helps to define the components and applications.
Q #17) Are there any CSS (styles) provided by Salesforce.com for Supported Lightning
Components?
Answer: Yes, this is available in Salesforce Lightning Design System.
Q #18) Are Lightning components meant only for mobile apps?
Answer: With a responsive design in mind, Lightning components are meant to be mobile-first. The
components help to build responsive apps faster for desktops, tablets, and mobile.
Q #19) Is it possible to include external JavaScript/CSS libraries in components?
Answer: Yes, multiple libraries can be used such as JavaScript/CSS libraries, jQuery, Bootstrap, etc
from a local, static resource.
Q #20) Is it possible to integrate lightning components with a framework such as Angular?
Answer: It is possible to insert the third-party code within a Visualforce page. The same Visualforce
page is then put inside a Lightning component. Then the same Lightning Component is used in
another Lightning component that works for various environments.
Q #21) Do you create an App Bundle first to create a Lightning component?
2
3
Q #24) Are there any options for Lightning Record Page Assignment?
Answer: It can be assigned in different ways, such as:
Org default
App Default (overrides the assignment at the org level)
App Record Type Profile (overrides the assignment at the org and app level).
Q #25) How to create a custom Lightning Record Page?
Answer: We can create it with the following steps:
Setup->App Builder in Quick Find Box->Select Lightning App Builder-> New->Record Page->
Name the page as <xxx>Select Opportunity->Choose Header, Sub header, Right Sidebar template
and Click Finish.
Please go through the link for further details on creating a custom Lightning Page.
Q #26) What are the types of Lightning Record Pages in Salesforce?
Answer: Here are the types enlisted below:
App Page
Home Page
Record Page
Q #27) What are the attributes? What are the parameters required?
Answer: Attributes are the variables for storing values. The attribute is defined with a name, type,
default, description, and access. The <aura:attribute> tag is used that requires the values of name
and type attributes.
However, name and type are the only required parameters. This is shown below:
Q #28) Which interface to use if you want your component to be available for all pages?
Answer: You can use the flexipage:availableForAllPageTypes interface.
Q #29) Which interface can be used to get the id of the record from the record Detail page?
Answer: The force:hasRecordId interface can be used for getting rid of the record from the record
Detail page.
Q #30) Which interface should be used to override a standard action?
Answer: Here you can make use of the Lightning:actionOverride interface.
Q #31) Which interface is for using components in a quick action?
Answer: The interface used here is force:lightningQuickAction.
Q #32) Which interface to use a component in the record home page?
Answer: The interface used here is flexipage:availableForRecordHome.
Q #33) Which interface is used if you want a component to be used as a tab?
Answer: The interface used here is force:appHostable.
Q #34) Why Lightning:isUrlAddressable interface is used?
Answer: The lightning:isUrlAddressable interface is used when navigating to the component and
also when the component to be navigated implements this interface.
Q #35) How to find data changes using data handlers?
Answer: You can configure a component for invoking a change handler when the value of the
attributes in one of the many components changes.
3
4
Answer: A component event is fired from the instance of a component. It can be handled by the
event that fired the event or by the component in the containment hierarchy, receiving the event.
There are capture and bubble phases for the propagation of component events.
Q #37) What are application events?
Answer: An application event is fired from an instance of a component. It follows a publish-
subscribe model. The components that provide a handler for the event are notified. The phases
supported by the framework are capture, bubble, and default phase for the propagation of application
events. The capture and bubble phases have similarities with DOM handling patterns.
Q #38) What are the phases in component events propagation?
Answer: The two phases are:
Bubble phase
Capture phase
Q #39) What is Lightning Out?
Answer: Lightning Out is a powerful and flexible feature that allows you to embed the Lightning
web components on any web page. While using this, you do not need to deal with authentication or
even configure a connected app, and this simplifies some of the details when used with Visualforce.
Experience: A set of modern user interfaces optimized for speed. This includes
the Lightning Experience, Salesforce1 Mobile app and template-based
communities.
Lightning Component Framework: A JavaScript framework and set of standard
components that allow you to build reusable components to customize the
Lightning Experience, Salesforce1 Mobile app and template-based communities
and build your own standalone apps.
Visual Building Tools: Drag-and-drop technologies for fast and easy app building
& customizations. Use the Lightning App Builder to customize the Lightning
Experience and Salesforce1 Mobile app. Use the Community Builder to customize
template-based communities.
Lightning Exchange: A section of the AppExchange where you can find 70+
partner components to jumpstart your development.
Lightning Design System: Style guides and modern enterprise UX best practices
to build pixel perfect apps that match the look and feel of the Lightning
Experience and Salesforce1 Mobile app.
4
5
Aura is the open source technology that powers Lightning Components. The aura:
namespace contains all of the basic building blocks for defining components and
applications.
5
6
6
7
Component Event– Scope of this event is within itself or the parent component
of this event, all the components declared within the parent component would
get notified of this event.
System Event- these are the events fired by Salesforce’s system during the
lifecycle of the lightning app.
Application events are used to communicate any change in the component to a broader
audience. Any component who has registered for this event will get a notified.
Application events are best used for something that should be handled at the application
level, such as navigating to a specific record. Application events allow communication
between components that are in separate parts of the application and have no direct
containment relationship.
A bundle doesn’t have a suffix. Definition files can have one of these suffixes:
.app Application
.cmp Component
7
8
.design Design
.evt Event
.intf Interface
.css Style
.auradoc Documentation
1. We have to first Add the Lightning Components for Visualforce JavaScript library
to your targetted Visualforce page using the tag.
2. Next we have to create and refer a Lightning app which is used to the component
dependencies.
3. Lastly we need to write a JavaScript function which will finally create the the
component on the page using $Lightning.createComponent()
9
10
For more details please refer to below post lightning spinner and Lightning Spinner in
LWC (Lightning Web Component)
10
11
action override in Lightning Experience or the Salesforce app, and so on. This interface
has no effect except when used within Lightning Experience, the Salesforce mobile app,
and template-based communities.
Lightning pages are referred as FlexiPages in API and referred as Lightning pages
elsewhere in SFDC documentation.
11
12
c is component controller helps us to link with event handlers and action for the
component
wire ?
cached data from client side storage without waiting for server trip.
12
13
1. @wire(getBoats,{boatTypeId : this.boatTypeId})
getBoats(error,data){}
Will the above code deploy? (Assuming all variables and apex class
function exists).
@wire(getBoats,{boatTypeId : ‘$boatTypeId})
answeres]
If I want to refresh the wired data in the above function, can I call
refreshApex(this.someVar) ?
@wire(getBoats,{boatTypeId : ‘$boatTypeId’})
getBoats({error,data}){
if(data){
this.someVar = data;
this.error = undefined;
}
else if(error){
this.error = error;
this.someVar = undefined ;
}
}
Ans:
No we cant call refreshApex(this.someVar) rather refreshApex is called on
whole result provisioned from the wire service not just the data part, we will
have to rewrite it as below :
@wire(getBoats,{boatTypeId : ‘$boatTypeId’})
getBoats(result){
this.mainResult = result;
if(result.data){
13
14
this.someVar = result.data;
this.error = undefined;
}
else if(result.error){
this.error = result.error;
this.someVar = undefined ;
}
}
Now we can refresh data as refreshApex(this.mainResult)
below :
searchBoats(event){
@wire(getBoats,{boatTypeId: ‘$boatTypeId’}
getBoats(data,error){
}
}
Assume searchBoats is being called on click of button? Will I be able to
deploy the code ?
Ans: No you cant call it like this , code will not deploy. You will receive error
as leading decorators must be attached to class which means decorators like
wire can be directly under class only not inside any other function.
Similarly if you try to define variable with @track or api decorator inside a
function it will fail.
component ?
Ans: Wired service is called right after component is created ie after
constructor and is again called when parameter that you are passing is made
available.
14
15
15
16
Event.preventDefault()?
16
17
Headless actions : Which dont have any html file rather just logic
For headless action you have to define @api invoke method which
is auto called and recordID will be set after this function is called.
answers]
Ans:
transaction failed.
promise object.
Promise.all is used when I want to make sure once all promises are
components ?
17
18
code.
called upon.
ComponentName ?
Ans: We should never use “id” in lwc as id that you will define in
and C ?
then from A call attribute / function exposed (as @api) and pass
Ans: These type of events can bubble up inside dom and also able
component ?
Ans: No
8. Is bubble : false and composed : true possible in an event ?
Ans: No
19
20
Ans: In most simple words callback hell occurs when there are many functions
you want to call async and you end up puting them one side each another and
as the code grows it becomes very difficult to read for example :
getData(function(x)
{
getMoreData(x, function(y)
{
getMoreData(y, function(z)
{ ... }
);
});
});
block scoped
Var allows you to redeclare same variable while let will throw an
error
Var variables are hoisted that is you can access them even before
they are declared in code its just they will return undefined value
20
21
LWC follows kebab case ie if you are adding any LWC component
inside another component you will have to add in kebab case form
6. What is LMS ?
detail page?
Ans: Using navigation mixin only you can also create new record
where you define object , action as new and pass any default values
it ?
criteria.
21
22
importing
Ans: Both are used to compare two variables but == doesnt take
=== case if data type is not same it will always return false.
For example :
For example:
literals.
Template literals are created using (`) backtick character apart from
string interpolation they also are used for adding multi-line strings
22
23
true) imperatively ?
Ans: Yes
@AuraEnabled(cacheable= true)?
refreshes the LDS cache providing you the latest data this will work
Otherwise we will have to call the function again from our js to get
the latest data.
in LWC?
Ans: This error usually occurs when you are trying to make changes
= {someVariable % 7==0}
can do is create getter which will evaluate value for us which we can
illegal for example below piece of code will throw you an error
export default class someClass extends LightningElement {
const someVar = ‘someValue’ ;
23
24
Ans: We can query all of them using one query selector only no
need to write multiple for each tag. We can pass all tags (,)
Ans: Yes you will receive an error “Maximum depth exceeded” as in set
function you are again setting statusVal itself which means it will keep on
setting itself (infinitely).
24
25
25