Salesforce lightning interview questions and answers

  1. What are the type of events into Salesforce Lightning component
    1. Application Event(Salesforce Document)
    2. Component Event
    3. System Event(Salesforce Document)
  2. What is the basic difference between Application Event and Component Event
    1. The major difference between application and component event is that component event is used in the child to parent components and application event can be used throughout the application and any component can handler the application event.
  3. Which interface need to implement so that you can use the lightning component as the quick action.
    1. force:lightningQuickAction
  4. Which interface need to implement so that you can use the lightning component as Tab like custom object and VF page.
    1. force:appHostable
  5. Can we use Lightning Component into VF page? If yes how?
    1. Yes, using lightning out the functionality of the salesforce lightning component.
    2. For more details
  6. How can we call child component controller method from the parent component controller method?
    1. Yes, we can call using aura methods.
    2. Salesforce Document
  7. What are the different Lightning component bundles?
    1. Component
    2. Controller
    3. Helper
    4. Style
    5. Document
    6. Design
    7. SVG
    8. Renderer
    9. More Info Here(Salesforce Document)
  8. What is the use of Document and Renderer in the lightning component?
    1. Document: – A description, sample code, and one or multiple references to example components
    2. Client-side renderer to override default rendering for a component.
  9. How to ensure FLS while working with Lightning Component?
    1. Lightning Data Services already ensures Field Level Security and we can also use the Apex using isAccessible, isCreateable, isDeleteable, isCreateable and etc methods of Schema class.
  10. Why we should go for Lightning Component instead of VF pages?
  11. What is the difference between a lightning tag and UI tags?
    • A lightning tag has inbuilt SLDS we do not need to put extra effort to improve the look and feel, also it has may awesome tags to handle the Error or bad inputs. Error handling is very easy for lightning tags.
  12. What is the Difference between Lightning tags and Force tags?
    • The main difference between the Lightning tags and force tags is force tags works as apex:inputField tags work on the VF page. For example, if we are using forceInputField for the picklist field then it will show the input in picklist format with the respected values. It also supports the lookup/master input fields
  13. How can we navigate from one component to another component?
    • Yes. With the help of lightning:navigate tag and then use the page reference in JS Controller.
  14. In case of Parent to Child Component why we should use Component event instead of Application Event?
    • Because of the security issue as Application Event can be handled by any component so sensitive data be compromised

What are the tools included in lightning ?

  • Lightning Component Framework – Components and extensions that allow you to build reusable components, customize the Salesforce1 Mobile App, and build standalone apps.
  • Lightning App Builder – A new UI tool that lets you build apps lightning fast, using components provided by Salesforce and platform developers.
  • Lightning Connect – An integration tool that makes it easier for your Force.com app to consume data from any external source that conforms to the OData spec.
  • Lightning Process Builder – A UI tool for visualizing and creating automated business processes.
  • Lightning Schema Builder – A UI tool for viewing and creating objects, fields, and relationships.

What is Aura? Why do I see the aura: namespace in the code?

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.

Is Lightning an MVC framework?

No, it’s a component-based framework.

What is difference between Visualforce Components and Lightning Components?

Visualforce components are page-centric and most of the work is done on the server. Lightning is designed from the component up, rather than having the concept of a page as its fundamental unit. Lightning Components are client-side centric, which makes them more dynamic and mobile-friendly.

Where we can display lightning component?

There are a number of possibilities for display lightning component..

  •  Lightning Experience: We can display component in the Lightning Experience using the App Builder. We can edit the home page, edit a record detail page or create/edit a new app page to include it.
  •  Salesforce1 Mobile app: We can display component in the Salesforce1 Mobile app by creating a custom Lightning tab that references it and adding that tab in mobile navigation.
  • Standalone Lightning app: By create a standalone Lightning app (e.g. myapp.app) and include component in this app. Access Lightning app by URL.
  • Add Apps to the Lightning Experience App Launcher: Your Lightning Components apps and custom tabs are available from the App Launcher.
  • Add Apps to Lightning Experience and Salesforce App Navigation:  You can add Lightning components tabs to an app and they display as items in the app’s navigation bar.
  • Lightning App Builder and Community Builder : We can display component in template-based (e.g. Napili) community using the Community Builder. Build custom user interfaces using your own Lightning components, or those you install from AppExchange, for desktop and mobile devices.
  • Add Lightning Components to Lightning Pages: A Lightning Page is a custom layout that lets you design pages for use in the Salesforce mobile app or in Lightning Experience. You can use a Lightning Page to create an app home page and add your favorite Lightning component, such as the Expenses app we’ll be creating in this module, to it.
  • Add Lightning Components to Lightning Experience Record Pages: You can customize Lightning Experience record pages by adding a Lightning Component.
  • Launch a Lightning Component as a Quick Action: Create actions using a Lightning component, and then add the action to an object’s page layout to make it instantly accessible from a record page.
  • Create Stand-Alone Apps: A standalone app comprises components that use your Salesforce data and can be used independently from the standard Salesforce environment.
  • Run Lightning Components Apps Inside Visualforce Pages: Add Lightning components to your Visualforce pages to combine features you’ve built using both solutions. Implement new functionality using Lightning components and then use it with existing Visualforce pages.
  • Run Lightning Components Apps on Other Platforms with Lightning Out: Lightning Out is a feature that extends Lightning apps. It acts as a bridge to surface Lightning components in any remote web container. This means you can use your Lightning components inside of an external site (for example, Sharepoint or SAP), or even elsewhere on the platform such as on Heroku.
  • Customize Flow Screens: Create a flow to guide your users through a business process. By default, you can add simple fields like inputs or radio buttons to a flow screen. But with a custom Lightning component, you can fully customize the look-and-feel and functionality of your screen.

What are the different Lightning component bundles?

  • Component :UI for lightning component
  • Controller: Contains client-side controller methods to handle events in the component.
  • Helper: JavaScript functions that can be called from any JavaScript code in a component’s bundle
  • Style: Contains styles for the component.
  • Document: A description, sample code, and one or multiple references to example components
  • Design: File required for components used in Lightning App Builder, Lightning pages, or Community Builder.
  • SVG: Custom icon resource for components used in the Lightning App Builder or Community Builder.
  • Renderer: Client-side renderer to override default rendering for a component.

Click Here for official Salesforce documentation.

What is Lightning Experience?

Lightning Experience is the name for the all new Salesforce desktop app, with new features, built with a modern user interface and optimized for speed.

What is 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. 

What happens to my existing Visualforce Pages?

They’ll continue to be supported in the current UI and Lightning Experience. See the Trailhead module on this topic.

What are the type of events into Salesforce Lightning component?

  • Application Event – Scope of this event is throughout the lightning App and any component which has registered for this event would get a notification.
  • 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.

What is the basic difference between Application Event and Component Event?

Component events are used to do communication between child and parent. They use bubbling and capture same as used in DOM events. A change in a child component can be communicated to the parent component via component event.

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.

Component events vs Application events. Which one I should use?

Component events can only be handled by components above them in the containment hierarchy, therefore, their usage is localized to the components that need to know about them.

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.

What is aura definition bundle?

A bundle contains an Aura definition and its related resources. The definition can be a component, application, event, interface, or a tokens collection.

An AuraDefinitionBundle component is a folder that contains definition files. Unlike most other metadata components, an AuraDefinitionBundle component isn’t a single file, it’s a collection of files. Each file represents a resource in a bundle, such as markup, applications, code files (including controllers and helpers), events, documentation, and interfaces.

A bundle doesn’t have a suffix. Definition files can have one of these suffixes:

SuffixComponent Type
.appApplication
.cmpComponent
.designDesign
.evtEvent
.intfInterface
.jsController, Helper, or Renderer
.svgSVG Image
.cssStyle
.auradocDocumentation
.tokensTokens collection

What is the use of implements in lightning component?

Implements is use to refer platform interfaces which enables a component to be used in different contexts or to grant access to extra context data, a component can implement more than one interfaces.

Which interface we are supposed to implement so that a lightning component can be used as a Tab?

We need to implement the following “force:appHostable” so that we can use the component as a Tab.

Which interface we are supposed to implement so that a lightning component can be used as quick action?

We need to implement the following “force: lightningQuickAction” so that we can use the component as a Quick Action.

Which interface we are supposed to implement so that a lightning component can be used in Community builder?

We need to implement the following “forceCommunity:availableForAllPageTypes” so that we can use the component in community builder.

What is use of @AuraEnabled annotation

How to call apex class from lightning component

The AuraEnabled annotation enables Lightning components to access Apex methods and properties.

The AuraEnabled annotation is overloaded, and is used for two separate and distinct purposes.

  • Use @AuraEnabled on Apex class static methods to make them accessible as remote controller actions in your Lightning components.
  • Use @AuraEnabled on Apex instance methods and properties to make them serializable when an instance of the class is returned as data from a server-side action.

Can we Include One Lightning component to another ?

Yes we can include one Lightning component inside another Lightning component

How can we use Lightning Components with the Salesforce1 Mobile App ?

We can create a custom Lightning tab that points to our component and include that tab in our Salesforce1 Mobile navigation.

How can we use a lightning component in a VisualForce Page?

A Lightning component can be embed in any webpage using a very powerful and flexible feature, Lighting out. When used with Visualforce some complexity becomes simpler.
Lightning component can be added to Visualforce page in three steps:

  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()

Can we integrate Lightning components with another framework like Angular?

Yes, we can integrate lightning with any 3rd party framework.

Can we include external JavaScript/CSS libraries like jQuery, bootstrap in components?

Yes, we can use multiple libraries in our lightning component like JQuery, Bootstrap, custom CSS and custom Javascript libraries using static resource.

What is use of aura:method tag in salesforce lightning?

We can use <aura:method> to define a method as part of a component’s API. This enables you to directly call a method in a component’s client-side controller instead of firing and handling a component event. Using <aura:method> simplifies the code needed for a parent component to call a method on a child component that it contains.

How to ensure FLS while working with Lightning Component?

FLS and CRUD are not automatically enforced in the lightning component whenever any object is referenced in the Apex Controller and the component will display the fields and records for which the users do not have access. Therefore we should manually enforce the FLS and CRUD in the Apex Controller. Also when we use Lightning Data service  it takes care of FLS and CRUD for us.

How can we display loading spinner in lightning component?

Spinners are CSS loading indicators that should be shown when retrieving data or performing slow computations. lightning:spinner displays an animated spinner image to indicate that a request is loading. This component can be used when retrieving data or performing an operation that takes time to complete.

aura:waiting and aura:donewaiting can be used for controlling the loading spinner.

How can we conditionally display content in lightning component?

We can use aura:if to conditionally display content in lightning component. For more details refer to below post 

What is the use of force:hasRecordId interface?

or

How to get current record id in lightning component?

Add the force:hasRecordId interface to a Lightning component to enable the component to be assigned the ID of the current record. The current record ID is useful if the component is used on a Lightning record page, as an object-specific custom action or 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.

What is a FlexiPage in lightning?

FlexiPage represents the metadata associated with a Lightning page. A Lightning page represents a customizable screen made up of regions containing Lightning components.
A Lightning page can contain upto 25 components. Flexi page are stored as xml file and can be deployed using metadata api or any deployment tool.

Lightning pages are referred as FlexiPages in API and referred as Lightning pages elsewhere in SFDC documentation.

How can we deploy lightning components?

Lightning components can be deployed similar to any other component using changeset, ant migration tool, eclipse or any other migration tool.

What Is Lightning Data Service?

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 not needing Apex, Lightning Data Service improves performance and user interface consistency. Main advantage of using lightning data service is that we can perform basic operations without Apex code.

What is Locker Service in Salesforce Lightning?

Locker Service is a powerful security architecture for Lightning components. Locker Service enhances security by isolating Lightning components that belong to one namespace from components in a different namespace. Locker Service also promotes best practices that improve the supportability of your code by only allowing access to supported APIs and eliminating access to non-published framework internals.

What are value providers in Salesforce Lightning ?

Value Providers in lightning Component encapsulate related values together and used to access data. In Salesforce lightning, we have two value providers for a component they are v (View) and c (Controller).

  • v is component attribute set which helps to access component attribute values in markup
  • c is component controller helps us to link with event handlers and action for the component

What are List of Global value providers in lightning?

  • $globalID
  • $Browser
  • $Label
  • $Locale
  • $Resource

How to create popup in lightning component?

Modals/Popup Box are used to display content in a layer above the app. This paradigm is used in cases such as the creation or editing of a record, as well as various types of messaging and wizards.

If you have any other useful question answer related to Salesforce Lightning Interview Questions, please add in comment section.

Please refer to below links for more detail about lightning:

Lightning FAQ

Lightning Design System

Lightning Experience Rollout Specialist

Lightning Component Framework Specialist

Lightning Experience Specialist

Lightning Components Developer Guide