0% found this document useful (0 votes)
41 views44 pages

LWC Development Guide and JavaScript Basics

The document provides a comprehensive guide on Lightning Web Component (LWC) development, covering topics such as LWC introduction, environment setup, component creation, and integration with Apex and Lightning Data Service. It also includes JavaScript fundamentals, event handling, and SFDX command usage for managing scratch orgs and deployments. Additionally, it discusses naming conventions, data binding, and automation tools within Salesforce.

Uploaded by

jarshmi417
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views44 pages

LWC Development Guide and JavaScript Basics

The document provides a comprehensive guide on Lightning Web Component (LWC) development, covering topics such as LWC introduction, environment setup, component creation, and integration with Apex and Lightning Data Service. It also includes JavaScript fundamentals, event handling, and SFDX command usage for managing scratch orgs and deployments. Additionally, it discusses naming conventions, data binding, and automation tools within Salesforce.

Uploaded by

jarshmi417
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

LWC Development

1. Introduction of LWC

 Introduction of LWC
 ECMAScript Script 7
 Difference between Aura Component & LWC
 Advantages of LWC
2. Setup Environment and scratch Org

 Setting up the Development Environment


o Setup Visual Studio Code
o Install Command Line Interface
o Explain all commands (org:create, org:delete,..etc)
o Connecting VS code with Salesforce Org
o How to create scratch org
o Pull or push the source code
3. Create LWC


Create Basic LWC Component
 Understand the Web Components Folder Structure
 Modules in Lightning Web Components
 Data Binding
 Decorators for properties (@wire,@track,@api)
 Behavior of properties
 Create LWC Actions (onClick, onChange..etc)
 Data flow in Lightning Web Components
 Setter & Getter methods
 Iterators in LWC
 Invoking methods on child components
 All about Slots
 Lifecycle Hooks
 Hooks in LWC
 Shadow Dom Web Standard
4. LWC with SLDS

 Design the Fields


 Design the Buttons
 Design the Cards
 Design the data table
 Design the forms
 Scrollbars
 More examples
5. Event

1
 How to dispatch and handle events
 How Event Retargeting works?
 Event Propagation in JavaScript
 Event bubbling in child and parent components
 All Event propagation scenarios
 Programmatically handle the events
 Publish-Subscribe events
6. LWC & APEX

 Invoke apex method Imperatively


 Call apex method from LWC Component
 Call apex method from LWC Component with parameters
 Handling Errors
 Handling Exceptions
 Continuation
 Continuation Limits
7. Lightning Data Service

 Introduction
 Putting the base component lightning-record-edit-form to use
 Using lightning-record-view-form and lightning-record-view-form
 Using getRecord() Adapter
 Handlers in LDS base components
 Override save functionality using base components
 Using createRecord() method to create a record
 Using updateRecord() method to update a record
 getRecord() alternative syntax
8. Navigation in LWC

 Navigation to different destination from a Web Component


 Navigation in Files

2
3
4
5
-------------------------------------------------------------------------------------------------

For picture location in HTML

Src =[Link]
JavaScript

JavaScript

6
 JavaScript is a scripting or programming language that allows you to implement
complex features on web pages
 It brings interactivity to the web pages

Variables

 Variables are the containers for storing data values


 var, const and let are the reserved keyword to declare a variable
 JavaScript identifiers are case-sensitive.
 You can assign a value to a variable using equal to (=) operator when you declare it
or before using it.
Keyword const let var
Global scope No No Yes
Function Scope Yes Yes Yes
Block Scope Yes Yes No
Can be reassigned No Yes Yes

 let variables can be updated but not re-declared;


 const variables can neither be updated nor re-declared.

Data types in JS

There are 8 basic data types in JavaScript.


1. number 2. string 3. boolean 4. bigInt

5. undefined 6. null 7. object 8. Symbol

Rest all types are Object in some form

7
1. Array
2. Date
3. Math
4. String
5. etc.

Equability Comparison

== This operator does value comparision. Example 100 ==‖100‖

=== This operator does value plus data type comparison Example 100===‖100‖

Spread Operator

The operator‘s shape is three consecutive dots and is written as: …

1. Expanding string – Convert string into list of array


 let greeting = "Hello Everyone";
 let charsList = [...greeting]; ‗H‘,‘e‘,‘l‘,‘l‘…….

2. Combining Array- Combine array or add value to array
 let arr1 = [1, 2, 3];
 let arr2 = [4, 5, 6];
 let combined = [...arr1, ...arr2];
 [Link](combined); // [ 1, 2, 3, 4, 5, 6 ]

1. Combining Object – Combine object or add value to object


2. Creating New Shallow copy of Array and Object

Destructuring

The two most used data structures in JavaScript are Object and Array

8
Destructuring is special syntax that allows us to ―unpack‖ arrays or objects into a bunch of
variables, as sometimes that‘s more convenient.

 Array destructuring
 Object destructuring

let arr =["amazon", "google", "microsoft", "apple"];


let [compnay1, compnay2, compnay3, compnay4] = arr;
[Link](compnay1); // amazon

let options ={
title:"Zeroto to Hero",
description:"Learn JavaScript",
Age : 30,
type:"CRM"
}
let {title, description, Age, type} = options;
[Link](title); // Zeroto to Hero

String Interpolation-(`${}`)
 String interpolation allow you to embed expression in string
 Template string use the back-ticks(``) rather then the single or double quotes.
(`${firstName} ${lastName}`);

recordId= 2774444;

[Link](`[Link] // complete url

String methods
 JavaScript provides many methods to play with strings. Below are some of the most
commonly used srings method in LWC
[Link]() [Link]()

[Link]() [Link]() [Link]()


[Link]()
[Link]()

9
Object/JSON Operation

[Link]() [Link]() [Link]() [Link]()

 [Link]() method converts a JavaScript object or value to a JSON string


 [Link]() method returns an array of a given object's own enumerable property
names, in the same order as that provided by a for...in loop
 [Link]() method returns an array of a given object's own enumerable
property values, in the same order as that provided by a for...in loop
 [Link]() method parses a JSON string, constructing the JavaScript value or
object described by the string

Array Methods
1. map() - loop over the array and return new array based on the value return.
a. let newArry = [Link](function(element, index, array) {
b. [Link](`Element: ${element},Index: ${index}, Array: ${array}`);
c. return element * 2; // Example operation: double each element
d. });
2. every() - return true or false if every element in the array satisfy the condition
a. return element >=18; o/p true
3. filter() - return new array with all the elements that satisfy the condition
a. let filteredArray = [Link](function(element, index, array) {
b. return element > 5; // Example condition: keep elements greater than 5
c. });
4. some() - return true if at least one element in the array satisfy
5. sort() - sort the elements of an array
a. let sortedArray = [Link](function(a, b) {
b. return a - b; // Example: sort in ascending order
c. });
d. [Link](sortedArray); // Output: [2, 3, 5, 6 , 7, 8, 9, 10]
6. reduce() - this method reduces the array to a single value (left to right)
7. forEach() - this method calls for each array element(it never retun)

Promise

10
 Promise is an object that may produce a single value sometime in the future.
 Promise is used to handle asynchronous operation in JavaScript.

A promise has three states


1. Pending()
2. Fulfilled()
3. Rejected()

Use case from LWC point of view


1. Fetching data from server(is always asynchronous)
2. Loading file from system

Export

Exporting – Use export keyword to export many variables or much method from a file
export const name = "John Doe";

export function getName() {


return "John Doe";
}

Default export – Use export default keyword to export only one variable or method from a
file
export default user = "Salesforce Hero";

Import

Importing – Use import keyword to import variable or method from a given file path or
module.

Multiple imports

Import {name, getName} frm :/filepath

Import all exported members

11
Import * as tutils from :/filepath

Import a module with a default member

Import user from :/filepath

querySelector

The querySelector() method returns the first element that matches a specified CSS
selector(s) in the document.

[Link](selector);

querySelectorAll

The querySelectorAll() method returns all elements in the document that matches a
specified CSS selector(s), as a static NodeList object.

[Link](selector);

Event

An event is an action that occurs in the web browser, which the web browser feedbacks to
you so that you can respond to it.

For example, when users click a button on a webpage, you may want to respond to this
click event by displaying a alert box.

Event handler - It is a block of code that will execute when the event occurs. It is also
known as an event listener.

Two Common ways to add events

1. HTML Event Handler attribute - When we add event through HTML, Event always
begin with on keyword like onclick, onchange, onkeyup

2. Event Listener - Event Handlers provide two main methods for dealing with the
registering/deregistering event listeners:

 addEventListener() - register an event handler


 removeEventListener() - remove an event handler

Event Propagation

12
Event Propagation explains the order in which events are received on the page from the
element where the event occurs and propagated through the DOM tree.

There are two main event models

1. Event bubbling
2. Event Capturing

Event Bubbling

In the event bubbling model, an event starts at the most specific element and then flows
upward toward the least specific element (the document or even window).

Custom Event

In JavaScript we can create our own custom event using CustomEvent constructor

Syntax

new CustomEvent("eventName", {options})

Arrow Function
Arrow function allows us to write shorter function syntax.

13
Example:

abc = data=> {operation} --for parameter types

abc= (data1, data2) => {operation} – for two parameterstypes

Benefits of Arrow function


Arrow syntax automatically bind this to surrounding code‘s context.

LWC(Lightning web component)


Lightning Framework
The Lightning Component framework is a Ul framework for developing single page
applications for mobile and desktop devices.

Lightning Components using two programming models.

1. Aura Components Model


2. Lightning Web Component Model

List of Common SFDX Commands

1. Create Scratch Org

14
 Legacy SFDX Command:
sfdx force:org:create -s -f config/[Link] -d 30 -a recipes

 New SF Command:
sf org create scratch -d -f config/[Link] -y 30 -a recipes

 Changes:
o Add the scratch subcommand.
o The "assign default org" flag changes from -s to -d.
o The scratch org duration flag changes from -d to -y.

2. Push Source

 Legacy SFDX Command:


sfdx force:source:push

 New SF Command:
sf project deploy start

 Changes:
o A significant change; the new command works for all project formats (source or
metadata).

3. Delete Scratch Org

 Legacy SFDX Command:


sfdx force:org:delete -p -u recipes

 New SF Command:
sf org delete scratch -p -o recipes

 Changes:
 Add the scratch subcommand.
 The target org flag changes from -u to -o.

4. Assign Permission Set

 Legacy SFDX Command:


sfdx force:user:permset:assign -n recipes

 New SF Command:
sf org assign permset -n recipes

 Changes:

15
 The topic changes from user to org.
 The order of the subcommands changes.

5. Import Data Tree

 Legacy SFDX Command:


sfdx force:data:tree:import -p data/[Link]

 New SF Command:
sf data import tree -p data/[Link]

 Changes:
 Imports data using the same plan file with slight changes in syntax.

6. Open Org
 Legacy SFDX Command:
sfdx force:org:open -p lightning/n/Hello

 New SF Command:
sf org open -p lightning/n/Hello

 Changes:
 Opens the specified Lightning component in the org.

7. Run Apex Tests


 Legacy SFDX Command:
sfdx force:apex:test:run -c -r human -w 20

 New SF Command:
sf apex test run -c -r human -w 20

 Changes:
 Command is updated with equivalent flags for test execution.

8. Go through this website for both sfdx and sf commands

[Link]

Naming Conventions for LWC

16
camelCase : Each word in the middle of the respective phrase begins with a capital
[Link]

PascalCase: It is same like Camel Case where first letter always is capitalized.

kebab-case: Respective phrase will be transferred to all lowercase with hyphen(-)


separating words.

Case Name camelCase PacalCase Kebab-Case


Example helloWord HelloWord hello-word
Usage Component Name Component class Component
Name reference and
HTML attribute
Name

App creation and component Deployment

Data Binding in HTML Template

Data binding in the Lightning web Component is the synchronization between the controller and the
template (HTML).

17
Things to remember
1. In template we can access property value directly if it's primitive or object.
2. Dot notation is used to access the property from an object
3. LWC doesn't allow computed expressions like Names[2] or {2+2}
4. The property in { } must be a valid JavaScript identifier or member expression. Like {name} or
{[Link]}
5. Avoid adding spaces around the property, for example, { data }

kkkkk

18
Data Import Wizard Vs Data Import Wizard

Supports custom objects and a few Supports custom objects, and all
standard objects. standard objects.
Can import up to 50,000 records. Can import up to 5 million records.
Can insert, update and upsert records. Can insert, update, upsert and delete
records.
Does not support data export. Supports data export.
Field mappings cannot be saved Field mappings can be saved.
Can bypass workflow rules and Cannot bypass workflow rules and
processes processes.
Does not require software installation Requires Software installation.
Does not provide a command-line Provides a command-line interface
interface.

DATA EXPORT SERVICE

Data Export service can be used to export org data in monthly or weekly schedule
(depending on edition). Data export is also called as 'Data Export Wizard'.

Setup > Data export

The export can be scheduled in a weekly and monthly basis. The time, start date and end
date can be specified

Salesforce Automation tool

 Flow Builder, Process Builder, Workflow, and Approvals are declarative tools that
can be used to automate repetitive business processes.

Workflow

A workflow operates as a single if/then statement where an action is performed if a


defined criteria is met in a workflow rule.(Single If else condition)

How to start? (Record Create or Record Update)

When it runs?(Immediately or Delayed (time based))


 Tasks—Assign a new task to a user, role, or record owner.
 Email Alerts—Send an email to one or more recipients you specify.
 Field Updates—Update the value of a field on a record.

19
 Outbound Messages—Send a secure, configurable API message (in XML format) to a
designated listener.

WORKFLOW : What is it flow

Workflow has been an admin's friend for a long time. worknows can:

 Update a field
 Send an email
 Create a Task
 Send an outbound message (communication with another system)

These can be initiated when a record is created, whenever it meets a certain condition, or
whenever it is first set to meet a certain condition. The actions can be performed in any
combination and can even have a time delay, rather than be performed immediately.

Lets create workflow

 Let's send an email when a new employee is created in the org.


 Set Priority of the Case to High when the Customer Priority is set to Premium.

Email Template

1. Classic Email Template


2. Lightning Email Template

Example of Email that receives after record is created.

Dear,

All of us at GenWatt are glad to have as a customer.

I would like to introduce myself as your Account Manager. Should you have any
questions, please feel free to call me at or email me at info@[Link].

You can also contact GenWatt on the following numbers:

Main: 810-545-1000

Sales: 810-545-1222

Customer Service & Support: 810-545-1333

Fax: 810-545-1001

20
I am confident GenWatt will serve you well and hope to see our relationship grow over
the years.

Best Regards,

Tejram Jatav

✅Visualforce Basic Questions with Clear Answers

1. What are expressions used in Visualforce pages to bind with controllers?

Expressions in Visualforce pages are used to bind data between the page and the controller
using getter, setter, and action methods.

 Getter method: Retrieves data from the controller and displays it on the
Visualforce page.
 Setter method: Sends or saves data from the Visualforce page to the controller.
 Action method: Performs an action such as navigation or execution of logic when a
button or link is clicked.

�These methods allow interaction between the user interface and backend logic.

2. What is the purpose of controllers in Visualforce?

Controllers act as the bridge between the user interface (Visualforce page) and the data.

 They provide access to the data and logic needed by the page.
 They control what data is shown, how it behaves, and what happens when a user
takes an action (like saving or editing).

3. Which objects have associated standard controllers?

All standard and custom objects in Salesforce that are accessible through the API have
standard controllers.

21
 Examples: Account, Contact, Opportunity, and even your custom objects
like Employee__c.
 These controllers allow basic operations like viewing, editing, and saving records
without writing code.

4. What is included with each standard controller?

Each standard controller includes:

 �Data access: It allows access to the fields of the record and related data (parent
and child records).
 �Standard actions: Such as view, edit, save, delete, and cancel.

�These actions make it easy to work with records without writing custom logic.

5. When do you need to go beyond a standard controller and write custom


Apex code?

You should write a custom controller or controller extension when:

 You need complex business logic not supported by the standard controller.
 You want to display or manipulate data beyond what the standard actions allow.
 You need to integrate with external systems, callouts, or create multiple record
types at once.

�Example: Automatically sending an email or updating related records on save.

6. Compare and contrast custom controllers and controller extensions. How


are they similar and how are they different?

Similarities:

 Both allow custom Apex code to control data and logic.


 Both are used to extend the behavior of Visualforce pages.

Differences:

Feature Custom Controller Controller Extension

Based on standard Yes, extends a standard or custom


No, written from scratch
logic controller

22
Feature Custom Controller Controller Extension

Full control over logic and Adds or overrides standard


Flexibility
data functionality

Building fully customized Adding a button to perform a custom


Example Use Case
logic action

�Use custom controllers when you want full control.


�Use controller extensions when you want to reuse and extend existing functionality.

Here is the improved and easy-to-understand version of the Visualforce Interview Questions (Part 2)
from your screenshot:

7. What identifies a controller as being an extension?

A controller is considered an extension when it includes a constructor that accepts a


standard or custom controller as a parameter.

�Example:

public myControllerExtension([Link]
stdController) {
Account acc = (Account)[Link]();
}

�This is used to extend or add custom logic on top of standard functionality.

8. Why are properties helpful in controllers?

Properties simplify controller code by automatically generating getters and setters, which
makes the code easier to read and maintain.

 Saves time during development.


 Makes code cleaner, especially when reviewing or debugging.

9. In what order do methods fire within a controller?

There is no fixed order, but typically:

23
 Setters run before action methods.
 Action methods (like save, delete) run based on user interaction.

�There is no guaranteed full order apart from this rule.

10. What are some Apex classes commonly used in controllers?

Some useful classes include:

 [Link]
 SelectOption (for dropdowns)
 PageReference
 [Link]

These help in building Visualforce functionality and UI behavior.

11. How are wizard controllers different from other controllers?

Wizards handle multiple pages and steps and must maintain the state across those steps.

 They allow for step-by-step input (like a multi-page form).


 Use ViewState or custom logic to keep data between pages.

12. What are the effects of using the transient keyword?

The transient keyword prevents variables from being stored in ViewState.

�Use it for temporary data like calculations or intermediate results.


�Avoid storing large objects without it, as it increases ViewState size.

13. When is a component controller required for custom components?

When you use a custom Visualforce component and need custom logic to control
rendering or actions, then a component controller is needed.

 Example: If a component displays dynamic content or makes decisions .

14. What kind of content can be included in a Visualforce page?

You can include anything that browsers support:

24
 HTML
 JavaScript
 CSS
 Even Flash files or embedded media

15. What do {!expressions} refer to in Visualforce?

These are binding expressions used to access variables, methods, or properties from
controllers.

�Example:

<apex:outputText value="{![Link]}"/>

This binds the Name field of the account object from the controller.

16. What are the ways that Visualforce pages can be incorporated into your
user interfaces?

You can include Visualforce pages in your UI using:

 Links – Navigate to a page using a link.


 Buttons – Call the page with custom logic.
 Tabs – Create a dedicated tab for a Visualforce page.
 Inline Frames (iFrames) – Embed a Visualforce page inside a standard layout.

�These allow seamless integration of Visualforce with the standard Salesforce interface.

17. Is it always necessary to know Apex to create Visualforce pages? When does
it become necessary?

No, Apex is not always required. You can use standard controllers and components to
build simple Visualforce pages.

Apex is required only when:

 You need custom business logic.


 You want to perform complex operations (like calculations or DML).
 You need to fetch/manipulate data that is not available in standard controllers.

25
18. What are attributes in Visualforce? What is the syntax for including them?

Attributes are modifiers used in Visualforce components or tags. They allow you to pass
values or settings to components.

�Syntax:

<apex:component attributeName="value" />

�Example:

<apex:inputText value="{![Link]}" />

Here, value is an attribute.

19. What are the types of bindings used in Visualforce? What do each refer to?

There are 3 main types of bindings in Visualforce:

1. Data Bindings – Connect to controller variables.


o Example: {![Link]}
2. Action Bindings – Trigger controller methods.
o Example: <apex:commandButton action="{!save}" />
3. Component Bindings – Reuse components and pass data between them.

20. What is the main difference between using dataTable and pageBlockTable
tags?
Tag Purpose

dataTable Used for custom formatting and design.

pageBlockTable Used for standard Salesforce layout and structure.

�Use pageBlockTable when using standard Salesforce styles, and dataTable


when you need full control over the design.

21. Which tag is used with radio buttons and picklists to create selectable
values?

�Use:

26
<apex:selectOption>

This tag defines the available options in a dropdown (picklist) or a group of radio buttons.

22. How many controllers does a page have? Where is the controller for a page
assigned?

 A page has one main controller.


 You can also add extensions or custom components that act like mini-controllers.
 The controller is assigned using the controller or standardController
attribute in the <apex:page> tag.

�Example:

<apex:page standardController="Account"
extensions="myCustomExt">

23. There are a series of layout components that help recreate the traditional
Salesforce layout easily. What name do they share?

They all use the pageBlock family of components:

 <apex:pageBlock>
 <apex:pageBlockSection>
 <apex:pageBlockTable>

These mimic standard Salesforce layouts and are ideal for user-friendly pages.

24. Which tag should be used to automatically bring in Salesforce label and
default widget for a field?

�Use:

<apex:pageBlock>

It brings in field labels and default UI elements that match the Salesforce standard layout.

25. What are static resources?

Static Resources are files that you can upload to Salesforce and reference in Visualforce
pages. These can include:

27
 Images
 CSS files
 JavaScript files
 ZIP files

�Example:

<apex:includeScript value="{!URLFOR($[Link])}"/>

Use them to style or enhance your Visualforce pages.

26. What are some examples of JavaScript Events?

 onmouseover
 onclick
 onchange, onblur, etc.

These events trigger JavaScript functions or Visualforce logic based on user interactions.

27. What is AJAX typically used for in Visualforce?

AJAX is used to refresh only a part of the page instead of the full page.

�Helps with performance and better user experience.


�Uses tags like <apex:actionRegion>, <apex:actionSupport>.

28. What is the purpose of <script> tags?

The <script> tag allows developers to write JavaScript code directly in the page.

�This helps in adding interactivity, validation, and dynamic behavior.

29. What are the different AJAX action tags and what do they do?
Tag Purpose

actionStatus Shows the status of an AJAX request (like loading spinner).

Calls controller action on a specific event (e.g., onclick,


actionSupport
onblur).

28
Tag Purpose

actionPoller Automatically calls a method at a timed interval (for live updates).

actionFunction Links a JavaScript function to call Apex code.

actionRegion Defines which part of the page should be updated in partial refresh.

30. How can you create partial page refreshes?

Use AJAX tags to update only a part of the page instead of reloading the entire page.

�Steps:

1. Wrap the section in <apex:actionRegion> or <apex:outputPanel>.


2. Trigger the update with an event (<apex:actionSupport> or button click).
3. The related controller method is executed.

31. Which tag is used with both radio buttons and picklists to create selectable
values?

Use <apex:selectOption> to create selectable choices for dropdowns or radio


buttons.

�Example:

<apex:selectOptions value="{!picklistValues}"/>

32. What is the purpose of creating attributes in components?

Attributes in components allow passing data and parameters into the component, making
them:

 Flexible
 Reusable across multiple pages
 Customizable for different use cases

�Example:

<apex:attribute name="title" type="String"


description="Component Title"/>

Here is the improved version of the content with easier explanation and extra clarity:

29
33. How can you access Visualforce component values into JavaScript?

Ans:
To access values of Visualforce components (like input fields, checkboxes, etc.) in
JavaScript, we use the $Component global variable. This helps us refer to components
in our JavaScript code, especially when we want to get or manipulate their values.

�Example Use Case:


Suppose you have an <apex:inputText> field in your Visualforce page like this:

<apex:inputText id="afield" value="{!someValue}" />

Now, if you want to access the value entered in this input field using JavaScript, you can
do so by referring to its ID using the $Component global variable.

�Code to Access the Field’s Value in JavaScript:

<script>
var a =
[Link]('{!$[Link]}').value;
alert("The value entered is: " + a);
</script>

�Explanation:

 {!$[Link]} dynamically generates the actual HTML ID for the


component.
 [Link](...).value fetches the current value entered
by the user.
 The result is stored in variable a, and we display it using alert().

�Why Use This?


This method is helpful when you want to interact with Visualforce components using
custom JavaScript logic, such as validations, dynamic UI changes, or calling remote
methods.

34. What are the Governor Limits in Salesforce?

Salesforce enforces Governor Limits to ensure shared resources are used efficiently
across users and orgs.

These limits control how much code can run and how much data can be processed in a
single execution.

30
✅Key Governor Limits (per execution):

Limit Type Trigger Class Test

Total number of SOQLs 20 100 -

Total number of records retrieved via SOQL 50,000 50,000 -

Total number of records retrieved in one SOQL 1,000 10,000 500

Total number of DML rows processed 10,000 10,000 -

Total number of DML statements 150 150 -

Total number of send email methods 10 10 -

Total heap size 300,000 bytes 3 MB 6 MB

�These limits help avoid overuse of server resources and crashing the system.

35. What is Multitenant Architecture?

Multitenant Architecture means that:

 All users and apps share a common infrastructure.


 They share a single code base and resources.
 Each user's data is isolated and secure.

�It's like many customers living in the same building but in separate apartments — safe,
isolated, and efficient.

36. What is Metadata-driven development model?

A metadata-driven development model means building apps by configuring settings


instead of writing code. Think of it as using blueprints like:

 Data models (objects, fields)


 Business logic (flows, workflows)
 UI layout (page layouts, apps)

�No code is required — everything is defined using metadata in Salesforce.

31
37. What is Apex?

Apex is a programming language used to write custom logic on the Salesforce platform.

Key points:

 It's similar to Java in syntax.


 Runs directly on Salesforce servers.
 Can be used in:
o Triggers (for automating actions)
o Classes and methods (for reusable logic)
 Supports unit testing.
 Can work with Visualforce, Lightning, and DML operations.

38. What are [Link] sites (now called Salesforce Sites)?

Salesforce Sites allow you to create public websites and applications hosted directly on
Salesforce. These can be accessed:

 Without login or password.


 Using Visualforce pages and custom URLs.
 To expose data like knowledge bases, forms, or applications.

39. What is the AppExchange Directory?

AppExchange is Salesforce‘s online marketplace for apps and components.

 Developers can list apps for others to install and use.


 Customers can explore, try, and download apps.
 Similar to Google Play or Apple App Store — but for Salesforce!

40. What is the difference between Native Components and Composite


Components?
Type Description

Built-in Salesforce components (like objects, fields, flows). Fast and simple to
Native
use.

32
Type Description

Created by combining multiple components (e.g., Apex, APIs, custom UIs).


Composite
More powerful and flexible.

�Native = Speed & Simplicity


�Composite = Control & Flexibility

✅Visual Comparison Table from Image:

Feature Native Composite

UI Metadata, Layouts Visualforce, Custom links

Logic Workflows, Formulas, Approvals Apex, Web services

Data Custom Objects External APIs, Local DBs

Examples Expense tracking, Asset mgmt Order entry, System integration

41. Name some Native Components in Salesforce

 Custom Objects
 Security (profiles, roles, sharing rules)
 Workflow rules & approval processes
 Reports and Dashboards

�These are built-in and don‘t require complex coding to use.

42. What are Custom Objects?

Custom Objects store data specific to your organization, like a database table.

Example use: Job Applications, Course Registrations, etc.

 Composed of custom fields.


 No need to write SQL — you can just point and click to create them.
 They hold structured data for your app.

33
43. What is a Database Table (in Salesforce)?

A database table stores information like a spreadsheet:

 Each row = record (e.g., job applicant)


 Each column = field (e.g., name, email)

�In Salesforce, Custom Objects act like database tables.

44. What is a database row or record?

A record (or row) is a single instance of an object in Salesforce.


�Example: Each row in the SW Engineer object represents one engineer.

45. What is a field?

A field stores one particular piece of information about a record.


�Example: Name, Email, Country — each is a field.

46. What are Relationships?

Relationships define how two objects in Salesforce are connected using common fields.

47. When do you use Roll-up Summary fields?

Use Roll-up Summary fields to show:

 Sum, Minimum, Maximum, or Count of a field in a related child object.

�Example: On an Account, you can roll up the total value of all related Opportunities.

48. What are the different types of Picklists and their differences?

There are 2 types of picklists:

Type Description

34
Type Description

Standard Picklist User can select one option only.

Multi-select Picklist User can select multiple options at the same time.

�Example: For a Job Role, we may use standard picklist; for Skills, multi-select.

49. What are Field Dependencies?

Field Dependencies help show only relevant picklist values based on another picklist's
value.

�Example:
If Continent = Asia, then Country picklist will only show India, China, etc.
�Makes forms easier and faster to fill.

50. What is the difference between Controlling and Dependent Fields?

 Controlling Field: The main field that affects another.


 Dependent Field: Changes its available values based on the controlling field.

�Example:

 Controlling: Country
 Dependent: City

51. What are Custom Formula Fields?

Formula Fields are calculated fields that:

 Perform math, text operations, or logic.


 Update automatically when referenced fields change.

�Example: A formula to calculate total salary: Base Salary + Bonus

52. What are Validation Rules?

Validation Rules ensure data is entered correctly.

35
 They stop the user from saving incorrect data.
 Based on custom logic you define.

�Example: Prevent saving if Age is less than 18.

53. What are Page Layouts?

Page Layouts control how fields and sections appear on a record page:

 What users see and edit


 What fields are required, read-only, or hidden

�Helps customize the view based on user roles.

54. What are the different types of Relationship Fields?


Type Description

Lookup Relationship Simple connection between two objects. Optional.

Master-Detail Strong link: child depends on parent. Deleting parent deletes


Relationship child.

�In Master-Detail:

 Parent controls sharing, ownership.


 Child records are deleted when parent is deleted.
 You cannot reparent a child record.

55. When do you use Master-Detail relationships?

Use when:

 You want child records to be tightly linked to parent.


 Child record cannot exist without the parent.

�Example:
Feedback (child) cannot exist without a Job Application (parent).

36
56. What is a Related List?

A Related List is a section on a record page showing records linked to the current one.

�Example: On Account, you see a list of related Contacts or Opportunities.

57. What is a Junction Object?

A Junction Object allows a many-to-many relationship.

�Example:

 Students ⬌ Courses
 Create a junction object called Enrollment

58. What is the difference between Object-Level Security, Field-Level Security,


and Record-Level Security?
Type Description

Object-Level Can a user access the object at all? (View, Create, Delete)

Field-Level Can a user see/edit specific fields?

Record- Can a user see specific records of that object? (Controlled by sharing rules,
Level roles)

�Together, these control what data a user can see and do in Salesforce.

�Example:
A user might see the Account object but not the Annual Revenue field, and also only see
records owned by their team.

59. What are Organization-Wide Defaults (OWD)?

Ans: OWDs define the baseline level of access a user has to records they do not own.

37
�Example:
We can set ―Contacts‖ to Private, so users can only see their own contacts unless extra
access is given using Sharing Rules or Role Hierarchies.

60. What are Role Hierarchies?

Ans: Role Hierarchies allow managers to automatically access all records owned by
users below them in the hierarchy.

�Example:
A Sales Manager can view all records owned by their Sales Reps.

61. What are Sharing Rules?

Ans: Sharing Rules allow us to open access to records for specific groups of users
beyond the role hierarchy.

�Used when:

 Teams at the same level (e.g., East vs. West Sales) need access to each other‘s data.

62. What is Manual Sharing?

Ans: Manual Sharing allows record owners to manually grant access to individual users
who wouldn‘t otherwise have access.

�Example:
If you're reviewing a case, you can share it with your manager directly.

63. What are Profiles?

Ans: A Profile defines what a user can do on Salesforce, including:

�Permissions it controls:

 Create, Read, Edit, Delete (CRUD) rights


 Visible Tabs and Apps
 Login hours and IP restrictions
 Page layouts and field-level access
 Object-level and record-level access

38
�Example:

 Sales Profile: Can manage Leads, Opportunities


 HR Profile: Can access Employee records

64. What is the difference between Roles and Profiles?


Aspect Profiles Roles

Define what a user can do Define what data a user can see (record
Purpose
(permissions) access)

Mandatory? Yes, every user must have one No, not mandatory

Affects? Object-level, field-level, app-level Record-level (hierarchy-based access)

�Example:

 Profile: Can create Contacts


 Role: Can view Contacts owned by users below in hierarchy

65. What is a Public Group?


Ans: A Public Group is a collection of users, roles, or other groups who need shared
access to certain records. For example, you can create a public group to include all users
in the Sales Department.
Public groups make it easier to share records with multiple users at once, rather than
sharing individually. They are useful in sharing rules, folder access, etc.

66. What is a Workflow?


Ans: A Workflow is an automation tool in Salesforce that performs specific actions like
sending email alerts, updating fields, or assigning tasks when certain conditions (called
criteria) are met in a record.
For example, if a lead's status changes to ―Qualified,‖ you can automatically send a
welcome email to the lead.

67. What are Workflow Rules?


Ans: A Workflow Rule defines the condition that triggers automated actions in
Salesforce. It includes:

39
 The criteria for when the rule should run.
 The actions to take (email, task, field update).
 These rules are used to automate tasks based on changes in a record.
Each rule is based on one object and triggers when its criteria are met.

68. What are Workflow Tasks?


Ans: A Workflow Task is an automatic task assigned to a user as part of a workflow rule.
It might remind someone to follow up, make a call, or complete an action by a specific
date.
You can define the task‘s subject, status, due date, and who should be assigned the task.

69. What are Workflow Field Updates?


Ans: A Workflow Field Update automatically changes the value of a field on a record
when workflow criteria are met.
For example, if an opportunity is marked ―Closed Won,‖ the stage field can be updated to
―Completed.‖

70. What are Workflow Email Alerts?


Ans: A Workflow Email Alert automatically sends an email using a specified email
template.
These alerts are sent when a workflow rule is triggered and can only be sent to valid email
addresses. For example, an email can be sent to a manager when a case is escalated.

71. What are Queues?


Ans: A Queue is a collection of records (like leads or cases) that do not yet have an
owner.
Queues help teams manage work efficiently by allowing users to pick records from the
queue and take ownership.
Support teams often use queues to manage incoming support cases.

72. What are Time-Dependent Workflow Actions?


Ans: These are actions that are scheduled to occur at a specific time after a record meets
workflow criteria.
Example: You can send a reminder email 5 days after a contract is created but not signed.

40
73. What are Email Templates?
Ans: Email Templates are pre-designed email formats that you can reuse for automation.
They save time and ensure consistency in communication like welcome emails or
approval notifications.

74. What is the Role of Approval Processes?


Ans: An Approval Process allows you to define a step-by-step approval path for records
like expenses, leave requests, or deals.
Each step can be assigned to specific users or roles. Actions (like sending emails or
updating status) happen based on whether the record is approved or rejected.

75. What are Approval Actions?


Ans: These are the actions that happen when a record is approved or rejected in an
approval process.
Example:

 Send an email to the submitter


 Update a field (like changing ―Status‖ to ―Approved‖)
 Assign a task to another user

76. What are the different types of reports that Salesforce supports?
Ans: Salesforce supports 4 main report types:

1. Tabular Reports – Simple list of records, like an Excel sheet.


2. Summary Reports – Group and summarize records, like totals by region.
3. Matrix Reports – Group records by rows and columns (like pivot tables).
4. Joined Reports – Combine data from multiple report types into one view.

77. What are Dashboards?


Dashboards visually represent reports using charts, graphs, and tables.
�Benefit: Help in quick decision-making based on real-time data.

78. What are the different Dashboard Components?

1. Chart – Visual graph of report data


2. Table – Display record counts and field values
3. Gauge – Shows performance with a single value
4. Metric – Similar to a gauge but without ranges

41
5. Visualforce Page – Custom content like HTML or a form

79. What are Custom Report Types?


Custom report types let you define which records and related objects are available for
reporting.
You specify:

 Primary object
 Related objects
 Fields
 Filters

80. What are Web Services?


Web services enable apps built on different platforms to communicate using standardized
XML or JSON formats.
�Example: A Java app and a Salesforce org can exchange data using REST API or
SOAP API.

81. What is a Custom Tab?


A custom tab displays custom object data or external web content in Salesforce.

82. What is a Workflow Outbound Message?


It sends data from Salesforce to an external system via a Web Service when triggered by a
workflow rule.

83. Who is a Running User?


The running user determines what data is displayed in dashboards or reports.
�Note: Data is only shown if the running user has access to it.

84. What is SOAP?


SOAP (Simple Object Access Protocol) is a protocol for exchanging structured
information using XML between systems.

42
89. What is SOQL?
SOQL (Salesforce Object Query Language) is used to fetch data from Salesforce using
SELECT queries.
�Example:

sql
CopyEdit
SELECT Name FROM Account WHERE Industry = 'Banking'

90. What is a Time Trigger?


Time triggers schedule workflow actions for a specific time after a rule is met.

91. What is a Primary Key?


A field in a database that uniquely identifies each record (like ID fields in Salesforce).

92. What is a Foreign Key?


A field in one table that links to the primary key of another. Used to establish relationships
between objects.

93. What is a Merge Field?


A placeholder in an email template that pulls data dynamically from records.
�Example: Dear {![Link]} inserts the contact's name into the
email.

94. What is a Tab?


A tab lets users access object records like Accounts, Contacts, or Custom Objects via
navigation bar.

95. What is S-Control?


S-Controls are older Salesforce components built using HTML and JavaScript.
They were used for custom UI but are now replaced by Visualforce and Lightning.

96. Will Visualforce still support Merge Fields like S-Control?


Yes. Visualforce pages can still use merge fields like {![Link]} to
dynamically insert data.

43
97. What are Apex Governor Limits?
Salesforce sets limits to ensure efficient processing. These include:

 Max SOQL queries


 DML statements
 Heap size
 Execution time
�Goal: Prevent any single org from monopolizing shared resources.

98. What is a Static Variable?


A static variable belongs to a class rather than a specific object.
It retains its value across multiple method calls or class instances.
�Use Case: Useful for managing state during a single transaction.

44

You might also like