Salesforce Developer Interview Questions
Salesforce Developer Interview Questions
Interview
Questions
By Ayush Rathore
Basic Salesforce Admin Questions
1. What is Salesforce?
Answer:
Salesforce is a cloud-based Customer Relationship Management (CRM) platform that helps
businesses manage sales, customer support, marketing, and automation. It offers tools like Sales
Cloud, Service Cloud, Marketing Cloud, and more.
Answer:
Objects are database tables in Salesforce where data is stored. There are two types:
Answer:
A Profile controls user permissions, field access, and object access. It defines what a user can
view, create, edit, and delete. Example profiles: System Administrator, Standard User.
Answer:
A Permission Set is a collection of settings and permissions that can be assigned to users in
addition to their profile. It helps provide extra permissions without changing profiles.
Answer:
Answer:
Record Types allow different page layouts and picklist values for different users within the
same object. Example: In the Opportunity object, different record types for Small Business
Sales and Enterprise Sales.
Answer:
A Page Layout controls how fields, sections, buttons, and related lists appear on a record’s
detail page.
Answer:
OWD defines the baseline level of access for records within Salesforce. It sets the default record
visibility for users who don’t own the record. Levels:
Answer:
Sharing Rules extend record access to users based on roles, public groups, or territories. They
are used when OWD is set to Private but we need to share specific records.
10. What is a Role Hierarchy?
Answer:
A Role Hierarchy allows record access to be automatically granted to users higher up in the
hierarchy. Example: A Sales Manager can see records of their Sales Reps.
Answer:
A Workflow Rule is an automation tool that performs actions like sending emails, updating
fields, creating tasks, or sending outbound messages when a certain condition is met.
Answer:
Answer:
Flow is a powerful automation tool that collects data, updates records, creates new records,
and makes complex decisions with clicks instead of code.
Answer:
Data Loader is a tool used to import, update, delete, and export data in bulk (up to 5 million
records). It is used when working with large data sets.
15. What are Validation Rules?
Answer:
Validation Rules ensure data quality by enforcing specific business rules before saving a
record. Example: A rule to ensure that the Phone Number field is always entered.
Answer:
A Report is a collection of filtered data presented in rows and columns. Types of reports:
Answer:
A Dashboard is a visual representation of multiple reports using charts, graphs, and metrics. It
helps monitor key performance indicators (KPIs).
Answer:
A Queue is a group of users who share responsibility for managing records. Example: A Case
Queue where support agents can pick cases to work on.
19. What are Public Groups?
Answer:
A Public Group is a collection of users, roles, and other public groups used to simplify sharing
rules and email alerts.
Answer:
An Approval Process automates record approval workflows. Example: A manager must
approve a discount request before finalizing a deal.
21. A sales team needs different picklist values than the support team. How would you
configure this?
Answer: Use Record Types with different picklist values for Sales and Support.
22. A user cannot see an Opportunity record. What will you check?
Answer:
Question: A user needs edit access to Contacts, but their Profile only allows read access. How
will you fix this without changing their Profile?
Solution:
• I will create a Permission Set that grants edit access to the Contact object.
• I will assign this Permission Set to the user.
• This allows additional permissions without modifying the user’s Profile.
Question: A sales representative cannot see an Opportunity record owned by a different team.
How will you troubleshoot?
Solution:
I will check:
1️. OWD (Organization-Wide Defaults) – If set to Private, users can’t see others’ records.
2️. Role Hierarchy – If the sales rep is below in the hierarchy, they may not have access.
3️. Sharing Rules – I will create a Sharing Rule to grant access to the required group.
4️. Manual Sharing – The owner can manually share the record if needed.
Best Practice: Use Role Hierarchy & Sharing Rules instead of manual sharing.
3️. Scenario: Restricting Field Editing
Question: A manager wants to ensure that only certain users can update the Discount field on
the Opportunity. How will you achieve this?
Solution:
• I will use Field-Level Security (FLS) to hide the Discount field from unauthorized
profiles.
• If certain users should see but not edit the field, I will create a Validation Rule:
Question: When a new lead is created, the system should send an email reminder to the
assigned sales rep after 3 days if the lead is not contacted. How will you set this up?
Question: A user reports that they cannot see a report in a shared folder. How will you fix this?
Solution:
I will check:
1️. Report Folder Permissions – Ensure the user has Viewer or Editor access.
2️. Object Permissions – Check if the user has access to the objects in the report.
3️. Field-Level Security – Ensure the fields in the report are visible to the user.
Question: Users are creating duplicate Accounts with the same name. How will you prevent
this?
Solution:
1️. Create a Matching Rule to detect duplicate Account Names.
2️. Create a Duplicate Rule to block duplicates or allow but alert users.
3️. Optionally, use Validation Rules to enforce specific naming conventions.
Best Practice: Use Duplicate Rules instead of Apex Triggers for standard duplication
checks.
Question: The Stage picklist in Opportunities should show different values for Sales Reps and
Sales Managers. How will you configure this?
Solution:
• Create two Record Types for Sales Reps and Sales Managers.
• Assign different picklist values to each Record Type.
• Ensure Profiles are assigned to the correct Record Type.
8️. Scenario: Automating Approval Process
Question: When a deal’s discount exceeds 20%, a manager must approve it before closing. How
will you configure this?
Question: A user reports that they cannot log in to Salesforce. How will you troubleshoot?
Solution:
1️. Check Login History – Look for errors like Incorrect Password or IP Restriction.
2️. Check Profile Login Hours – Ensure login is allowed at that time.
3️. Check IP Whitelisting – Ensure they are logging in from an allowed IP range.
4️. Check Multi-Factor Authentication (MFA) – Ensure they have completed MFA setup.
Question: You need to import 10,000 Contacts from an Excel file into Salesforce. How will you
do it?
Solution:
Alternative: If under 50,000 records, use Data Import Wizard for a simpler UI.
Basic Apex Interview Questions &
Answers
1️. What is Apex in Salesforce?
Answer:
Apex is a strongly-typed, object-oriented programming language used in Salesforce to
execute business logic. It is similar to Java and is designed to run on the Salesforce platform.
Apex allows developers to write triggers, controllers, batch jobs, integrations, and test
classes to customize and automate processes.
Answer:
Apex provides:
✔ Object-Oriented Programming (OOP) - Supports classes, interfaces, and inheritance.
✔ Database Integration - Works seamlessly with SOQL and DML statements.
✔ Governor Limits - Ensures efficient code execution to maintain multi-tenancy.
✔ Asynchronous Processing - Supports Batch Apex, Queueable Apex, and Future methods.
✔ Built-in Exception Handling - Provides robust error-handling mechanisms.
✔ Trigger-based Execution - Automates logic before or after DML operations.
Answer:
Apex supports:
✔ Primitive Data Types - Integer, Double, Boolean, String, Date, Datetime, Long,
Decimal.
✔ Collections - List, Set, and Map.
✔ Objects - Instances of standard/custom Salesforce objects (Account, Contact, etc.).
✔ Enums - Used to define a set of constant values.
4️. What are Apex classes and methods?
Answer:
An Apex class is a blueprint that defines variables and methods. A method is a function inside a
class that performs a specific action.
Example:
apex
This class has a method greet() that takes a name and returns a greeting message.
Answer:
Answer:
✔ List – Ordered collection, allows duplicates.
✔ Set – Unordered collection, does not allow duplicates.
✔ Map – Key-value pairs for fast lookup.
Example:
apex
Answer:
SOQL (Salesforce Object Query Language) is used to retrieve data from Salesforce objects.
Unlike SQL, it does not support JOIN but uses relationship queries.
Example:
apex
This SOQL query fetches Name and Email from Contact where LastName = 'Smith'.
Answer:
Example:
apex
Answer:
Governor Limits are restrictions imposed by Salesforce to ensure efficient use of resources in a
multi-tenant environment.
Key limits:
✔ SOQL Queries – Max 100 queries per transaction
✔ DML Statements – Max 150 DML operations per transaction
✔ CPU Time Limit – Max 10,000ms per transaction
✔ Heap Size – Max 6 MB for synchronous, 12 MB for async Apex
To avoid hitting limits, we must use bulkification, efficient SOQL, and optimized DML
operations.
10. What is the ‘with sharing’ and ‘without sharing’ keyword in Apex?
Answer:
✔ With Sharing – Enforces user’s security settings (CRUD, FLS, Sharing Rules).
✔ Without Sharing – Ignores security rules and runs with system-level access.
Example:
apex
Answer:
An Apex Trigger is code that runs before or after DML operations (insert, update, delete).
Types of Triggers:
✔ Before Trigger – Runs before the record is saved to the database.
✔ After Trigger – Runs after the record is saved.
Example:
apex
Answer:
Answer:
Trigger Context Variables provide metadata about the DML event.
Answer:
A Recursive Trigger occurs when a trigger calls itself indefinitely.
apex
public class TriggerHandler {
public static Boolean isTriggerExecuted = false;
}
1️5️. What are Future Methods in Apex? Why are they used?
Answer:
A Future Method in Apex runs asynchronously to perform long-running tasks, such as callouts
to external systems or heavy processing, without blocking the main execution.
Key Features:
✔ Runs in a separate thread
✔ Supports callouts (if callout=true is specified)
✔ Cannot return values or be called from another future method
Example:
apex
Use Case: If you need to call an external API, but Salesforce doesn’t allow callouts inside
triggers, you can use a future method to bypass this limitation.
Answer:
Queueable Apex is used for asynchronous processing, but it is more flexible than future
methods.
Key Differences from Future Methods:
✔ Supports chaining (one queueable job can trigger another).
✔ Allows complex objects like sObjects and Custom Objects.
✔ Better debugging & monitoring in Apex Jobs.
Example:
apex
To run it:
apex
Answer:
Batch Apex is used when we need to process large amounts of data asynchronously in chunks
to avoid governor limits.
Key Features:
✔ Divides records into small batches for processing.
✔ Can process millions of records.
✔ Uses Database.QueryLocator for efficient querying.
Example:
apex
To run it:
apex
Use Case: If you need to update 1 million records, a normal Apex trigger will hit governor
limits. Instead, you should use Batch Apex.
1️8. What is the difference between Future, Queueable, and Batch Apex?
Answer:
Future
Feature Queueable Apex Batch Apex
Method
Processing Type Asynchronous Asynchronous Asynchronous (Bulk)
Yes (one job at a Yes (via finish
Supports Chaining No
time) method)
Yes (millions of
Can Process Large Data? No No
records)
Callouts Allowed? Yes Yes Yes
Supports Complex
No Yes Yes
Objects?
1️9️. What is the difference between Database.insert() and insert DML statement?
Answer:
apex
Answer:
✔ Synchronous Apex – Runs immediately in a single transaction.
✔ Asynchronous Apex – Runs in the background to avoid blocking execution.
2️1️. What are Governor Limits, and how do you avoid hitting them?
Answer:
Governor Limits ensure that no single Apex transaction overuses resources in Salesforce’s
multi-tenant environment.
apex
for (Contact c : contactList) {
Account acc = [SELECT Name FROM Account WHERE Id = :c.AccountId]; // BAD!
}
Fixed Version:
apex
Answer:
@TestVisible is used to expose private methods and variables to test classes.
Example:
apex
Answer:
✔ Custom Metadata – Used to store configuration data that is deployable via metadata API.
✔ Custom Settings – Used for static application settings that can be accessed without SOQL
queries.
2️4️. What is the difference between @isTest and Test.startTest()/Test.stopTest()?
Answer:
✔ @isTest – Used to define test classes and methods.
✔ Test.startTest() & Test.stopTest() – Used to isolate governor limits for testing
asynchronous operations.
Example:
apex
@isTest
private class MyTestClass {
@isTest
static void testMethod() {
Test.startTest();
// Call the method that runs a future/queueable job
Test.stopTest();
}
}
Answer:
✔ Use Try-Catch Blocks
✔ Use Custom Exceptions
✔ Use Error Logging in a Custom Object
Example:
apex
try {
Account acc = [SELECT Id FROM Account WHERE Name = 'Test'];
} catch (Exception e) {
System.debug('Error: ' + e.getMessage());
}
Advanced Apex Interview Questions &
Answers
2️6️. How does Apex enforce security (CRUD, FLS, Sharing Rules)?
Answer:
Apex does NOT automatically enforce CRUD (Create, Read, Update, Delete), FLS (Field-
Level Security), or Sharing Rules. We must manually enforce them.
apex
if (Schema.sObjectType.Account.isAccessible()) {
Account acc = [SELECT Id, Name FROM Account LIMIT 1];
}
apex
if (Schema.sObjectType.Account.fields.Name.isAccessible()) {
Account acc = [SELECT Name FROM Account LIMIT 1];
}
apex
Answer:
✔ Before Triggers – Used to update records before they are saved to the database.
✔ After Triggers – Used when we need to use record Ids (e.g., inserting related records).
Example: Before Insert Trigger (Prevent Duplicate Accounts)
apex
apex
Answer:
Context variables help us determine when and how the trigger runs.
Answer:
A Custom Exception is a user-defined exception used to handle specific error cases.
Example:
apex
Answer:
A Wrapper Class is a custom class that wraps multiple objects together in a single unit.
Example:
apex
Use Case: Used in LWC or Visualforce pages to send multiple types of data.
Answer:
Platform Events enable real-time event-driven communication between systems.
Answer:
Answer:
The @AuraEnabled annotation exposes Apex methods to LWC or Aura Components.
Example:
apex
Answer:
✔ Using Http and HttpRequest Classes
apex
Answer:
Answer:
✔ List – Ordered collection of elements
✔ Set – Unique, unordered collection
✔ Map – Key-value pair storage
Example:
apex
Answer:
✔ Use Asynchronous Apex (Future/Queueable Methods)
✔ Limit Concurrent Callouts
✔ Batch Requests to Reduce API Calls
Answer:
Apex Email Service allows Salesforce to process incoming emails and send automated email
notifications.
Example: Inbound Email Handler
apex
Answer:
A Dynamic SOQL Query is built at runtime instead of being hardcoded.
Example:
apex
String query = 'SELECT Id, Name FROM Account WHERE Name LIKE \'%' +
searchTerm + '%\'';
List<Account> accList = Database.query(query);
Answer:
A Polymorphic SOQL Query is used when a field can refer to multiple objects.
Example: Querying the WhatId field on the Task object (which can be related to different
objects).
apex
Answer:
Apex follows the transaction model, where a group of DML operations are executed as a
single unit of work.
apex
Savepoint sp = Database.setSavepoint();
try {
Account acc = new Account(Name='Test Account');
insert acc;
// Simulating an error
con.LastName = null;
update con;
} catch (Exception e) {
Database.rollback(sp);
System.debug('Transaction Rolled Back: ' + e.getMessage());
}
4️2️. What is the difference between with sharing, without sharing, and inherited
sharing?
Answer:
Keyword Description
with sharing Respects the user's sharing rules.
without sharing Ignores the user's sharing rules.
inherited sharing Inherits sharing settings from the caller class.
Example:
apex
Answer:
To prevent record conflicts, we use:
1️. FOR UPDATE Keyword (Locks the record until the transaction completes)
apex
Account acc = [SELECT Id, Name FROM Account WHERE Id = '001...' FOR UPDATE];
acc.Name = 'Updated Name';
update acc;
Answer:
Salesforce imposes governor limits, so handling millions of records requires:
apex
4️5️.What is the difference between Future Methods, Queueable, and Batch Apex?
Answer:
When to Use?
Answer:
The Continuation class is used for long-running callouts (up to 120 seconds).
Example:
Answer:
✔ Use Developer Console → “Logs” Tab
✔ Use Limits Class
apex
Answer:
Finalizers execute code after Queueable Apex completes, even if it fails.
Example:
apex
Answer:
✔ Use Batch Apex for callouts (Set Database.AllowsCallouts=true)
✔ Use Continuation Apex for parallel processing
✔ Use Platform Events to avoid hitting callout limits
5️0️. What is Custom Metadata and how is it different from Custom Settings?
Answer:
apex
Answer:
✔ Bulkify SOQL/DML (Avoid loops)
✔ Use @AuraEnabled(cacheable=true) (for LWC caching)
✔ Use Query Plan Tool (For optimizing SOQL queries)
✔ Avoid Recursive Triggers (Use Static Variables)
Answer:
✔ Use System.debug() for logging
✔ Use Checkpoints in Developer Console
✔ Use Log Inspector to analyze Apex Execution
5️3. What is a Skinny Table in Salesforce?
Answer:
A Skinny Table is a performance optimization technique used to improve SOQL query
performance on large objects.
Answer:
✔ Generate Access Token using HttpRequest
✔ Use Authorization Header for API Calls
Example:
apex
Answer:
LWC (Lightning Web Component) is a modern framework built on web standards like
JavaScript, HTML, and CSS to create lightweight, fast, and efficient UI components in
Salesforce.
• Performance → LWC is faster because it uses native browser capabilities, while Aura
relies on a JavaScript framework.
• Syntax → LWC uses modern JavaScript (ES6+), making it more aligned with industry
standards.
• Shadow DOM → LWC uses Shadow DOM, providing better security and
encapsulation.
• Reusability → LWC components can be easily reused inside Aura components, but not
the other way around.
Answer:
LWC offers several advantages, making it the preferred choice for Salesforce development:
Performance → Faster execution due to native browser support.
Security → Uses Shadow DOM for encapsulation and better security.
Simplified Development → Uses modern JavaScript (ES6, ES7) and follows web
standards.
Better Debugging → Supports browser dev tools for easy debugging.
Reusability → Can be reused inside Aura components.
Lightweight → No extra framework like Aura, making it efficient.
Answer:
Every LWC component consists of three main files:
myComponent.html
myComponent.js
myComponent.js-meta.xml
Answer:
The .js-meta.xml file defines where and how the component can be used in Salesforce.
xml
CopyEdit
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"
fqn="myComponent">
<apiVersion>58.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__RecordPage</target>
<target>lightning__AppPage</target>
</targets>
</LightningComponentBundle>
Here,
✔ isExposed → Makes the component available for use.
✔ targets → Defines where the component can be used (Record Page, App Page, etc.).
Answer:
Shadow DOM is a web standard that encapsulates a component’s structure and styles within
itself, preventing external interference.
Benefits in LWC:
✔ Better Security → Other components cannot modify LWC’s styles.
✔ No CSS Conflicts → Ensures styles do not leak outside the component.
✔ Encapsulation → Keeps LWC components self-contained and reusable.
Example:
<template>
<p class="custom-style">This style is isolated!</p>
</template>
Even if a global CSS file has .custom-style { color: red; }, it won't affect this LWC
component due to Shadow DOM.
6️. What are lifecycle hooks in LWC? Name some commonly used ones.
Answer:
Lifecycle hooks are methods that execute at different stages of a component’s lifecycle.
Example:
connectedCallback() {
console.log('Component is added to the DOM');
}
7️. How do you pass data from a parent component to a child component in
LWC?
Answer:
Use the @api decorator to pass data from parent to child.
Parent Component:
Child Component:
8️. How do you pass data from a child component to a parent component in
LWC?
Answer:
Use Custom Events to pass data from child to parent.
javascript
CopyEdit
const event = new CustomEvent('mycustomevent', { detail: 'Hello Parent' });
this.dispatchEvent(event);
html
CopyEdit
<c-child-component onmycustomevent={handleEvent}></c-child-component>
javascript
CopyEdit
handleEvent(event) {
console.log(event.detail); // Output: "Hello Parent"
}
9️. What are decorators in LWC? Explain @api, @track, and @wire.
Answer:
Decorators enhance properties/functions in LWC.
Example:
javascript
CopyEdit
import { api, wire } from 'lwc';
export default class Example extends LightningElement {
@api publicValue;
@wire(getContacts) contacts;
}
Answer:
LWC uses standard JavaScript event handling.
Answer:
The @wire decorator automatically calls an Apex method and reactively updates the
component when data changes.
Apex Class:
apex
CopyEdit
public with sharing class ContactController {
@AuraEnabled(cacheable=true)
public static List<Contact> getContacts() {
return [SELECT Id, Name, Email FROM Contact LIMIT 10];
}
}
LWC JavaScript:
import { LightningElement, wire } from 'lwc';
import getContacts from '@salesforce/apex/ContactController.getContacts';
LWC HTML:
html
CopyEdit
<template if:true={contacts.data}>
<template for:each={contacts.data} for:item="contact">
<p key={contact.Id}>{contact.Name} - {contact.Email}</p>
</template>
</template>
Key Points:
✔ Use @AuraEnabled(cacheable=true) for better performance.
✔ The @wire decorator ensures reactivity and automatic updates.
Answer:
Imperative Apex calls run only when triggered (like a button click).
Apex Class:
@AuraEnabled
public static List<Contact> getContacts() {
return [SELECT Id, Name, Email FROM Contact LIMIT 10];
}
LWC JavaScript:
handleLoad() {
getContacts()
.then(result => {
this.contacts = result;
})
.catch(error => {
console.error(error);
});
}
}
LWC HTML:
Key Points:
✔ Imperative calls are triggered manually.
✔ They don’t cache data like @wire.
1️3️. What is the difference between @wire and imperative Apex calls?
1️4️. What are Lightning Data Services (LDS) in LWC? How do they work?
Answer:
LDS allows LWC to fetch, create, update, and delete records without writing Apex. It is
built on User Interface API and ensures security (CRUD, FLS, Sharing Rules) automatically.
<lightning-record-form
record-id="003XXXXXXXXXXXX"
object-api-name="Contact"
layout-type="Full">
</lightning-record-form>
Key Points:
✔ No Apex required!
✔ Automatically handles security (CRUD, FLS, Sharing Rules).
✔ Optimized → Uses Salesforce’s caching for better performance.
Answer:
Use NavigationMixin to navigate between Record Pages, Objects, Custom Tabs, or External
Links.
LWC HTML:
Key Points:
✔ Supports record pages, list views, objects, and external links.
✔ Uses NavigationMixin.Navigate().
1️6️. How can you style an LWC component? What are different ways to apply
CSS?
Answer:
LWC supports three types of styling:
1️. Component CSS (.css file) → Scoped to the component.
2️. Global CSS (SLDS) → Standard Salesforce Lightning Design System.
3️.Custom Styles with :host and :host-context → Advanced styling.
p {
color: blue;
font-size: 16px;
}
Key Points:
✔ Component styles do not leak outside.
✔ Use :host for custom component styles.
1️7️ How do you share data between two sibling components in LWC?
Answer:
Use Lightning Message Service (LMS) for sibling communication.
sendMessage() {
const message = { data: 'Hello from Publisher' };
publish(this.messageContext, MY_MESSAGE_CHANNEL, message);
}
}
connectedCallback() {
subscribe(this.messageContext, MY_MESSAGE_CHANNEL, (message) => {
console.log(message.data);
});
}
}
Key Points:
✔ LMS is best for sibling components.
✔ Works across Lightning Apps, Aura, and LWC.
You said:
yes
ChatGPT said:
Answer:
LWC does not automatically enforce security. You must handle:
1️. CRUD (Create, Read, Update, Delete) – Check if a user has permission on the object.
2️. FLS (Field-Level Security) – Ensure users can access specific fields.
3️. Sharing Rules – Control record visibility based on org-wide defaults & sharing rules.
@AuraEnabled
public static List<Contact> getContacts() {
List<Contact> contacts = [SELECT Id, Name, Email FROM Contact];
return (List<Contact>) Security.stripInaccessible(AccessType.READABLE,
contacts);
}
Key Points:
✔ Use Security.stripInaccessible() to prevent unauthorized field access.
✔ Use with sharing in Apex to enforce sharing rules.
Answer:
LWC supports three types of events:
Key Points:
✔ Use CustomEvent for parent-child communication.
✔ Use Lightning Message Service (LMS) for sibling components.
Answer:
Platform Events allow real-time communication across systems.
connectedCallback() {
subscribe('/event/MyEvent__e', -1, (event) => {
console.log('Received event: ', event);
});
}
Key Points:
✔ Used for real-time updates (e.g., order tracking, notifications).
✔ Uses CometD API for streaming.
2️4️. How do you integrate an external system with LWC using REST API?
Answer:
LWC cannot call external APIs directly due to CORS restrictions. Instead, use Apex Callouts.
@AuraEnabled
public static String fetchData() {
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api.example.com/data');
request.setMethod('GET');
HttpResponse response = http.send(request);
return response.getBody();
}
fetchData().then(result => {
console.log(result);
});
Key Points:
✔ LWC → Apex → External API to bypass CORS.
✔ Enable Named Credentials for authentication.
2️5️ What is Salesforce Connect, and how can LWC interact with external data?
Answer:
Salesforce Connect allows real-time access to external data without storing it.
✔ Uses External Objects (Account_External__x).
✔ Fetches data via OData, REST, or SOAP.
Key Points:
✔ No data storage needed in Salesforce.
✔ Ideal for large datasets from external systems.
Answer:
Create a Generic Component that accepts dynamic properties.
<template>
<lightning-card title={title}>
<slot></slot> <!-- Allows dynamic content -->
</lightning-card>
</template>
JS:
Key Points:
✔ Use @api to make properties configurable.
✔ Use slots for dynamic content inside the component.
Answer:
Feature Composition Inheritance
Combining components inside Extending from another
Definition
each other class
<c-child></c-child> inside class Child extends
Example Parent {}
Parent
Reusability More reusable Less flexible
Key Points:
✔ Use Composition (<c-child>) instead of inheritance.
✔ LWC does not support multiple inheritance.
Answer:
LWC uses JavaScript properties for state management.
✔ Use @track (older method, now automatic).
✔ Use @api for parent-child state sharing.
✔ Use Lightning Message Service (LMS) for app-wide state sharing.
increment() {
this.count++;
}
}
Key Points:
✔ LWC state is managed reactively.
✔ Use LMS for global state sharing.
Answer:
Method When It Runs Use Case
connectedCallback()
Runs once when component is Fetching data, setting up
inserted into DOM listeners
renderedCallback()
DOM manipulation, checking
Runs after every render
UI updates
Example:
connectedCallback() {
console.log('Component inserted in DOM');
}
renderedCallback() {
console.log('Component rendered');
}
Key Points:
✔ Use connectedCallback() for initial data loading.
✔ Use renderedCallback() carefully to avoid infinite loops.
Answer:
1️⃣ Use console.log() – Print values to the browser console.
2️⃣ Use Chrome DevTools – Inspect elements and view errors.
3️⃣ Enable Debug Mode in Salesforce – Helps in detailed error tracking.
4️⃣ Use try...catch blocks – Handle exceptions in Apex & JS.
5️⃣ Use @wire debug logs – Log wired method data.
Example:
try {
console.log('Data:', this.data);
} catch (error) {
console.error('Error:', error);
}
Key Points:
✔ Use Chrome DevTools & console.log() for debugging.
✔ Enable Debug Mode in Setup → Debug Mode.
What is Salesforce Integration?
Salesforce Integration means connecting Salesforce with other applications, databases, or
services to exchange data and functionalities. For example:
Why is it important?
1. Data Integration – Syncs data between Salesforce and other systems (e.g., CRM, ERP).
o Example: Integrating Salesforce with a database like MySQL.
2. Process Integration – Connects business processes across systems.
o Example: When an order is placed in an e-commerce site, it is automatically
created as an Opportunity in Salesforce.
3. User Interface (UI) Integration – Merges multiple applications into a single interface.
o Example: Embedding Google Maps inside Salesforce.
4. Security Integration – Ensures authentication and access control.
o Example: Using OAuth for single sign-on (SSO).
APIs allow Salesforce to communicate with other systems. There are two main types:
Other APIs:
• If your data is stored in another system (like SAP, SQL Server) but you want to access
it in Salesforce without storing it, use Salesforce Connect.
• It uses OData (Open Data Protocol) to fetch data in real time.
End Result: Whenever a lead is created, an automated WhatsApp message is sent using
Twilio.
Summary
Salesforce Integration helps in connecting Salesforce with other apps to automate processes
and sync data.
Before using APIs, make sure your Salesforce org has API access:
1. Go to Setup → Profiles
2. Open the System Administrator Profile
3. Scroll down to Administrative Permissions
4. Make sure API Enabled is checked
https://login.salesforce.com/services/oauth2/callback
1. Open Postman
2. Use the following URL (Replace your_client_id and your_client_secret):
https://login.salesforce.com/services/oauth2/token
https://yourInstance.salesforce.com/services/data/v58.0/sobjects/Account
4. Go to Headers → Add:
o Authorization: Bearer your_access_token
o Content-Type: application/json
5. Click Send
6. You will get the list of Accounts in JSON format
Steps
1. Open Postman
2. Select POST method
3. Use this URL:
https://yourInstance.salesforce.com/services/data/v58.0/sobjects/Account
{
"Name": "TechCorp Solutions",
"Phone": "9876543210",
"Industry": "Technology"
}
6. Click Send
7. Response will show "id": "001XXXXXXXXXXXXXXX", meaning the record is
created.
Now, let's update the Phone number of the Account we just created.
Steps
https://yourInstance.salesforce.com/services/data/v58.0/sobjects/Accoun
t/001XXXXXXXXXXXXXXX
{
"Phone": "1234567890"
}
4. Click Send
5. Response will show "204 No Content", meaning the update is successful.
Steps
https://yourInstance.salesforce.com/services/data/v58.0/sobjects/Accoun
t/001XXXXXXXXXXXXXXX
3. Click Send
4. Response will be "204 No Content", meaning the record is deleted.
Salesforce will call an external API to fetch weather details from OpenWeather API.
Steps
apex
System.debug(WeatherService.getWeather('Indore'));
xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="urn:partner.soap.sforce.com">
<soapenv:Header>
<SessionHeader>
<sessionId>your_access_token</sessionId>
</SessionHeader>
</soapenv:Header>
<soapenv:Body>
<query>
<queryString>SELECT Name FROM Account WHERE Id =
'001XXXXXXXXXXXXXXX'</queryString>
</query>
</soapenv:Body>
</soapenv:Envelope>
1. Enable Remote Site Setting (Setup → Remote Site Settings → Add API URL).
2. Write Apex Class to call API using HttpRequest.
apex
apex
@RestResource(urlMapping='/createAccount/')
global class AccountAPI {
@HttpPost
global static String createAccount(String name) {
Account acc = new Account(Name = name);
insert acc;
return 'Account Created with ID: ' + acc.Id;
}
}
• The external system can send a POST request with the Account name, and it will create
a new Account in Salesforce.
Example (Zapier)
POST https://login.salesforce.com/services/oauth2/token
Body:
- grant_type = password
- client_id = your_client_id
- client_secret = your_client_secret
- username = your_salesforce_username
- password = your_password+security_token
Summary
Integration Type Purpose
REST API Fetch/Send data (JSON)
SOAP API Fetch/Send data (XML)
Salesforce Callout Salesforce calls external API
External Webhook External system calls Salesforce
Salesforce Connect Access external data without storing
Middleware No-code automation between systems
Platform Events Real-time event-based integration
OAuth & Security Secure authentication