Interview Preparation for Salesforce


1. How to Create and update record in custom metadata.

CreateUpdateMetadataUtils implements Metadata.DeployCallback, object => MeataData.Container
Metadata.Operations.enqueueDeployment(mdContainer, callback); DML On Custom Metadata Salesforce 

2. How to prevent duplicate record entry in Lead,Account and contact or any objects?
Setup->Duplicate Rules and Matching Rule / OR Create Unique fields.

3. How to handle API timeout in salesforce?
Using Continuation Callout

4. What is callback url in connected app?
after successful authentication user will redirect toward
callback url(2000 char).
User will get access token.

5. What is access token and refresh token?
Authorization server and resource server

6. What is the query for fetching Account from contact?
[select Id, Name, Account.Name from contact]

7. How to lock record for Update in SOQL ?
[select Id,Name from Account FOR UPDATE] – All record will be lock.

8. What is the query for fetching all record(deleted record also)?
[select Id, Name from Account ALL ROWS]
Note : You can-not use ALL ROWS and FOR UPDATE together.

9. how to get most recent data View Account by SOQL ?
[select Id, Name from Account FOR VIEW]
[select Id, Name from Account FOR REFERENCE]

10. How to retrieve Queue using SOQL?
Queues are stored into Group Objects in Salesforce and Users that
are present are being stored into GroupMember Object. Use below SOQL
Queries.For All the Queues into Salesforce Org.
select Id from Group where Type = ‘Queue’ For Quering specific Queue.
select Id from Group where  Type = ‘Queue’ AND NAME = ‘QueueName’
// You can also use DeveloperName so that if you have used Queue
Name Developer Name Will be same SOQL will be like
select Id from Group where Type = ‘Queue’ AND DeveloperNAME = ‘Test_Queue’
// If QueueName is Test Queue the developer Name will be Test_Queue
If you want to query public groups/quques then use below SOQL.
select Id from Group where Type = ‘Public’ AND Developer_Name=’Test_Group’

11. Write SOQL to fetch 3rd and 4th Row from Account?
SELECT Name, Id
FROM Account
ORDER BY Name
LIMIT 4
OFFSET 2

12. Get All Account with order by Account Name and account who have null name should be come at last?
SELECT Name
FROM Account
ORDER BY Name DESC NULLS LAST

13. Write query to access all record from Contact where Billing City and Shipping City are same?
This is not possible in SOQL because salesforce doesn’t allow to
compare two field of same object in where clause.
Workaround : Create formula field(SameCity), compare Billing City
and Shipping City and return true
use this formula field into your where clause
Select Id, FirstName, LastName from Contact where SameCity = true

14. How to get recently viewed record by SOQL?
SELECT Id, Name
FROM RecentlyViewed
WHERE LastViewedDate !=null
ORDER BY LastViewedDate DESC

SELECT Id, Name
FROM RecentlyViewed
WHERE Type IN (‘Account’, ‘Contact’, ‘Plan__c’)
ORDER BY LastViewedDate DESC

SELECT Account.Name, Title, Email, Phone, Website__c
FROM Contact
WHERE LastViewedDate != NULL
ORDER BY LastViewedDate DESC

15. How to get Salesforce Logged In Users Using Apex?
List<AuthSession> asList = [Select Id, UsersId, Users.Name,
UserType, SourceIp, SessionType, SessionSecurityLevel,
ParentId,NumSecondsValid, LoginType, LastModifiedDate,
CreatedDate From AuthSession];
System.debug(‘asList-‘ + asList);

16. Way of using Group By clause in SOQL?
SELECT Industry, COUNT(Id) From Account GROUP BY Industry

17. Group by clause with having?
SELECT Industry, COUNT(Id) From Account GROUP BY Industry
HAVING Industry IN (‘Agriculture’,’Manufacturing’,’Construction’)

18. Group by Rollup Clause?
GROUP BY ROLLUP Clause is used to add subtotals to get aggregates
data in the query results. It returns multiple levels of subtotal
rows. We can add up to three fields in a comma-separated list in
GROUP BY ROLLUP Clause statement.

SELECT Industry, Type, COUNT(Id) From Account GROUP
BY ROLLUP (Industry, Type)

19. Group By Cube Clause?
GROUP BY CUBE clause is used in SOQL query to add subtotals for
all combinations of a
grouped field in the query results.

20. Group by cube clause and Order by clause?
SELECT Type, BillingCountry, GROUPING(Type) grpType, GROUPING(BillingCountry) grpCity,
COUNT(Id) accnts FROM Account
GROUP BY CUBE(Type, BillingCountry)
ORDER BY GROUPING(Type), GROUPING(BillingCountry)

21. SOQL Query Like With Multiple Values using LIKE operator?
Set<String> accountNameMatches = new Set<String> { ‘A%’, ‘B%’, ‘%C%’, ‘%D’ };
List<Account> accList = [SELECT Id FROM Account WHERE Name LIKE :accountNameMatches];
system.debug(‘accList-‘ + accList);

22. SOQL Query To Get Org Wide Code Coverage:?
SELECT PercentCovered FROM ApexOrgWideCoverage
Note: To run the query use Tooling API

23.SOQL Query to Get Activity History for a Record?
Following query is to get an Account record last 30 days activity histories.
SELECT Id, (SELECT Id, Subject, CreatedDate FROM ActivityHistories
WHERE CreatedDate = LAST_N_DAYS: 30) FROM Account WHERE Id = ‘0014K000002KAhT’

24. Get Related Contact with Account Query (Parent to child)?
Account[] acctsWithContacts = [SELECT Name, (SELECT FirstName,LastName
FROM Contacts) FROM Account WHERE Name = ‘SFDC Computing’];

// Get child records
Contact[] cts = acctsWithContacts[0].Contacts;
System.debug(‘Name of first associated contact: ‘
+ cts[0].FirstName + ‘, ‘ + cts[0].LastName);

25. Get Related child to parent for custom object depth 3 ?
[Select Id, B__r.Name, B__r.A__r.Name from C__c where Status =’Active’]

26. Where Clause over TextAreaField?
List<Project__c> projects = new List<Project__c>();
for(Project__c proj : [SELECT Name, Status__c, Description__c FROM Project__c
WHERE Name LIKE ‘%’ + String.escapeSingleQuotes(name) +’%’ +
OR Status__c = String.escapeSingleQuotes(status)]) {
if(proj.Description__c.contains(‘filter string’)) {
projects.add(proj);
}
}

27. What is Data Skew, Type of Data Skew and How to Overcome this problem?
Account data skew
Ownership skew
Lookup Skew

Account Skew?
The Account and Opportunity objects use the same sharing access.
So if a user has access to an account, she will
have similar access to all its child Opportunities.
When an Opportunity record is being updated (and therefore locked),
its parent Account also gets locked. And visa versa.
With both Account and Opportunity locked, your performance may be impacted.
Salesforce recommends that you avoid associating more than about 10,000
Opportunities to a single Account.
A simple solution could be to create a few different types of Accounts to
handle these Opportunities.

Owner Data Skew ?
When a large number of records of the same object type are owned by the same
user this is called Ownership Skew.
By deleting record or by changing owner of record.
Try to limit the children to 10,000 while designing the architecture,
for this you can assign the children by using the
Round Robin algorithm with the help of custom settings for the child
and parent objects.
You can adopt the public Read/Write sharing model, where the parent account stays
locked and the calculations still occur.
If the skewed accounts are there, then you can re-distribute the child objects
to reduce the record-level hurdles.

Lookup Skew?
When a very large number of records are associated with a single record via
the lookup relationship, this is called Lookup Skew.Such a relationship
can also lead to performance problems and should be avoided. use picklist
instead lookup

28. How to limit selections from multi-select Picklist?
Validation Rule :
IF(INCLUDES( Multi_Picklist__c, “A”),1,0) +
IF(INCLUDES( Multi_Picklist__c, “B”),1,0) +
IF(INCLUDES( Multi_Picklist__c, “C”),1,0) +
IF(INCLUDES( Multi_Picklist__c, “D”),1,0) +
IF(INCLUDES( Multi_Picklist__c, “E”),1,0) > 3

29. What is Named Credentials as Callout Endpoints?
Named Credentials – “using Named Credential, we can make call out to external
system without supplying username or Password”.
Org1 and Org2 – I want to get account from Org2 into Org1
Create Connected App = Org2
Create Authorization Provider = Org1
Define Named Credential = Org1
Use Apex to connect in 5 lines of code

HttpRequest feedRequest = new HttpRequest();
feedRequest.setEndpoint(‘callout:Salesforce_Org/services/data/v32.0’);
//callout:[Named Credential Name]/[Callout URL of other Salesforce Org]
feedRequest.setMethod(‘GET’);
Http http = new Http();
HTTPResponse feedResponse = http.send(feedRequest);
while (feedResponse.getStatusCode() == 302) {
feedRequest.setEndpoint(feedResponse.getHeader(‘Location’));
feedResponse = new Http().send(feedRequest);
}
System.debug(feedResponse.getBody());

30. What are Apex REST Annotations?
Use these annotations to expose an Apex class as a RESTful Web service.
@ReadOnly
@RestResource(urlMapping=’/yourUrl’)
@HttpDelete – Delete
@HttpGet – Get
@HttpPatch – Update
@HttpPost – Create
@HttpPut – Create or Update

RestRequest and RestResponse objects are available by default in your Apex
methods through the static RestContext object. This example shows how
to access these objects through RestContext:

RestRequest req = RestContext.request;
RestResponse res = RestContext.response;

31. Dataloader – How to avoid comma seperated value
field(Address field have comma seperated text)

take such kind of value in quote.
We can perform action in Dataloader :
Insert, Update, Upsert, Delete, Hard Delete,
Export, Export All (All record with deleted record also).
Allow Bulk API = True; to allow bulk insert.
Allow Null value = True; to insert null/blank value

32. Can we set Null as key in Map.?
– YES
Map<string,string> maap= new Map<string,String>();
maap.put(null, ‘Avinash’);
system.debug(‘==’+maap.get(null));

33. Account acc=[select id from account where name=’Avinash’];
Optimised code here.

List<Account> acc=[select id from account where name=’Avinash’];

34. How to check not null or certain value?
string s;
if(s==null || s==’dd’)
{
// do your action here
}

35. What are the causes of decrease test coverage of
classes in Prod envt?
Insufficient Setup Data
36. What is used of For Update in Soql? To lock record for certain
time(10 sec) to do operation.

37. How to toogle (Active/Deactive)Picklist value on the click of
button in lightning? 

38. What is two way binding in lightning?{!v.attr}(Value provider)

39. What are platform event? event driven architecture
“Enterprise Message Platform”?
There is subscriber and publisher communicate with each other
through event.
//Process builder, trigger, Batch
This is just like custom object. Suffix is “__e”
We can create custom fileds in platform event.
checkbox,date,datetime,number,text,textarea
Standard Field : Created By, Created Date, Replay Id
You can’t query SOQL or SOSL on Platform event
you can’t use platform event in report / listview/search
publish platform event cant be rollback
platform event fields are readonly
only after insert trigger are supported
you can access platform event through API and declarative
you can controll platform event through profile and permission.
you can raise platform event through Batch class by
implementing Database.RasesPlatformEvent
Trigger and subscription
EventBus.publish(publishEventObjects)

40. What is the CPU time exception? limit exception. when we
perform bulk operation
then probably it show this error.
Code should be optimized here.

41. SOQL character limit ? 20k characters.
(salesforce object Query Language)
Where clause char limit ? 4k char.
Total SOQL = 100
Total Record = 50000

42. SOSL record limit? 20k chars
(Salesforce object search language)
Total SOSL? 20
Total Record = 2000

43. Few Example of SOSL as below
Query Editor:
FIND {Avinash} IN ALL FIELDS Returning User(Id,Name,Email),
Lead(Id,Name),Contact(Id,Name,LastName,Email)

FIND {Avinash} IN ALL FIELDS Returning User(Id,Name,Email),
Lead(Id,Name),Contact(Id,Name,LastName,Email
where Email=’[email protected]’)//With where clause

FIND {Avinash} IN ALL FIELDS Returning User(Id,Name,Email),
Lead(Id,Name),Contact(Id,Name,LastName,Email
order by Name)//With Order by

FIND {Avinash} IN ALL FIELDS Returning User(Id,Name,Email),
Lead(Id,Name),
Contact(Id,Name,LastName,Email limit 10)//with limit

Anonymous window:
List<List<sObject>> searchList = [FIND ‘Wingo OR SFDC’ IN ALL FIELDS
RETURNING Account(Name),Contact(FirstName,LastName,Department)];
Account[] searchAccounts = (Account[])searchList[0];
Contact[] searchContacts = (Contact[])searchList[1];

44. Difference between SOSL and SOQL ?
SOSL : (Salesforce object search language)
record limit : 2000
work on multiple object
serach on text, email and phone

SOQL:(Salesforce Object Query Language)
Record Limit : 50k
Work on single object or related obect
Can not use text area, encrypted field in where clause.
We can not compare two column of same object in where clause.
Cant use ALL ROWS and FOR UPDATE together.

46. What are collection in Apex ?
Map? collection – key value pair -> key is always unique
Set? Unique Set – Unorder collection of element which contain
only Unique keys
List? Order collection of element which contain duplicate values.

47. What is lightning framework? : this is UI framework from aura.
Browser compatible.
Device compatible for desktop mobile etc.
Increase performance.
Loosely coupled.
two way binding.
Separation of code is main advantages of this framework.
Component Bundle -> Component->
Controller->
Helper->
Style->
Renderer-> To do DOM manipulation after default renderer. Render,renderer,
afterRender, unrender
Documentation-> mydomain.salesforce.loghtning.com/AuraDocs
Design-> We use <design:attribute> node to make lightning component
attribute available for administrators to edit in Lightning
App Builder.
SVG -> SVG resource is to define a custom icon for the lightning
component when it appears in
the Lightning App Builder’s component pane

48. To make a component available in App Builder?
The component needs to implement the flexipage:availableForAllPageTypes interface:
<aura:component implements=”flexipage:availableForAllPageTypes” access = “GLOBAL”>

49. How to Dynamically instantiate class in apex ?
String classname=’MyDynamicClass’;
ApexClass c=[Select Id,Name from ApexClass where Name =:classname];
Type mycls= Type.forname(c.Name);
myCls.newInstance();

50. How to call calling apex class method from javascript?
apex.js,connection.js
sforce.apex.execute(‘className’,’MethodName'{});

51. Can we access query instance from Start method to finish method?
yes by using Database.stateful
52. how to call another batch apex from first batch?
From Finish Method. you can call 5 batch
subsequently

53. How to bypass validation rule when upload bulk data
using data loader?

Take one Boolean field and check this field in validation rule.

54. How to Refresh Page using Lightning Web Component
eval(“$A.get(‘e.force:refreshView’).fire();”);

55. What are best practice to write test class?
Avoid SeeAllData=true,
Use DataFactory to create all data.
Always create bulky data for test class,
@isTest method ,
@testSetup only one ,
@TestVisible
Test.startTest()
Test.stopTest()

use Assert statement
System.assert()
System.assertEquals()
System.assertNotEquals()
System.runAs()

56. What are trigger context variables ? 
Before(insert,update,delete) and After (insert,update,delete,Undelete)
Context variable : Trigger.New,Trigger.Old,
Trigger.IsExecuting,Trigger.isBefore,Trigger.IsAfter,Trigger.isDelete,
Trigger.isInsert,Trigger.isUpdate
Trigger.NewMap,Trigger.OldMap
addError();

57. Best practice to write trigger?
write only one trigger.
Salesforce not sure about execution of sequence of trigger.
Trigger Should be bulkify,
Always use Trigger context variable.
Avoid DML or SOQL in Trigger,
All logic should be in helperclass.
Avoid Recursion of trigger.

58. How to restrict some user to read, write on fields from same profile ?
validation Rule. Trigger.

59. Order of salesforce execution and trigger? Where will be the Process builder
fall in order of execution.

System Validation
Before Trigger
Custom Validation
After Trigger
Assignment Rule (Lead/Case)
Auto response rule(Web2Lead/Web2Case)

workflow rule
if There is Update field using workflow -System Validation, Before Trigger
and After Trigger.

Escalation Rule

Executes the following Salesforce Flow automations, but not in a
guaranteed order.
Processes
Flows launched by processes
Flows launched by workflow rules (flow trigger workflow actions pilot

Rollup Summary and formula field execution
Criteria based sharing rule
Database commit
Post commit logic such as sending email and executing enqueued
asynchronous Apex jobs, including queueable jobs and
future methods.

Note:
Auto Response rule
Auto response rule fire only when the Lead/Case is submitted from Web2Lead /Web2Case from.
When you create the lead /case from UI cannot fire the Auto response rule.

60. How to call API from Batch ?
Database.AllowsCallout
61. How to write test class for Rest API Callout?
Implements HttpCalloutMock
62. What is significance of JWT or Access token ?
Oauth. To Authorised another system in Salesforce.
63. What are the function available in validation rule/formula fields ?
– DateTime(TODAY,WEEKDAY,YEAR, DAY,MONTH,HOUR,MINUTE, SECOND,Millisecond)
– Logical(AND, IF ,CASE, ISBLANK,ISNULL,ISNUMBER,ISNEW,NOT ,OR)
– Math(ABS,Ceiling,floor,Distance,Long,Max,min,mod,round,SQRT)
– Text(Left,Right,upper,lower,lpad,rpad,ispickal,includes,len,text,trim,substitute,contains,find)
– Adavanced(Currencyrate,ischanged,REGEX,vlookup)

64. Formula field has depth upto 15.

65. How to call Class and pass parameter from Processbuilder?
@InvocableMethod and pass parameter using set apex variable –
only one InvocableMethod can write.

The Invocable method must be static and public or global, and its
class must be an outer class.
Only one method in a class can have the InvocableMethod annotation.
Triggers can’t reference Invocable methods.
Invocable method will not accept more than one argument as a method
parameter Other annotations can’t be used with the
InvocableMethod annotation.
@InvocableMethod : Click Here for more details

66. What is significance of continuation callout?
Long running callout from visualforce page.
3 async callout in single continuation.
Make simultaneous callout.
chaining async callout.

67. What is External Object ?
External objects are similar to custom objects, but external object record
data is stored outside your Salesforce organization.
… Each external object is associated with an external data source
definition in your Salesforce organization.
An external data source specifies how to access an external system.

68. What is big Object?
massive amount of record can store. Billions. __b and you can not create
Big object directly. You have to use metadata with three files.

69. What are relationship in salesforce and How to Create
One to One Relationship in Salesforce?

Basically Salesforce offers two types of relationship:

One To Many Relationship
Many To Many Relationship (Using the concept of Junction object)
Sometimes we may need One To One relationship, But unfortunately
Salesforce doesn’t allow any
direct methodology to build One To one relationship.

Let’s consider the scenario that we want to establish a One to One
relationship between two
custom objects Employee__c and PAN_Card__c.
So, here are few ways to implement One To One relationship between
two objects in Salesforce. We
can achieve this by using configuration only and can also
achieve this by using code to make it more scalable.

Option 1:
Create a lookup field on PAN_Card__c to Employee__c.
Create a custom field on the PAN_Card__c object and make the field unique.
This field would be used to hold the ID of the associated Employee__c. H
ide this field from all page layouts. Create a Workflow rule on PAN_Card__c.
For any change of the lookup field on PAN_Card__c object, update the custom
field on the PAN_Card__c object with the value of the associated Employee Id.
We have established a one to one relationship between PAN_Card__c and
Employee__c. When we try to add a second PAN_Card__c to the Employee__c,
the “unique” constraint would be violated and an error would be thrown. T
his approach will work on both standard and custom object.

Option 2:
Create a master detail relationship on PAN_Card__c to Employee__c object.
Create a roll up summary field on Employee__c object of PAN_Card__c with
count type.Create a validation rule on Employee__c object rollup summary
field to check if count > 1.In this way also, We have established a
one to one relationship between PAN_Card__c and
Employee__c. So it will throw an error if Employee__c has more than
one PAN Card.

Option 3:
Create lookup fields on both objects PAN_Card__c and Employee__c,
to each other.Write triggers, for any change on these lookups, to either
copy the record ID into the other object’s lookup field when the other object’s l
ookup field is empty, or disallow the change to the original record
when the other object’s lookup field is already populated with a different
ID from the original record.This is already having a one-to-onePassport relation.

Option 4:
Create a trigger on PAN_Card__c object to check if the PAN Card record
already exists for an Employee. If it exist, then throw an error,
else allow the user to create.Here is the example for Employee__c
and PAN_Card__c object:
trigger PANCardValidation on PAN_Card__c (before insert, before update) {
Set<id> employeeIds = new Set<id>();
Map<id, Employee__c> mapEmployee = new Map<id, Employee__c>();

for (PAN_Card__c p : trigger.New) {
employeeIds.add(p.Employee__c);
}

List<Employee__c> lstEmployee = [SELECT Id, Name FROM Employee__c
WHERE Id IN : employeeIds];
if (!lstEmployee.isEmpty()) {
for (Employee__c emp : lstEmployee) {
mapEmployee.put(emp.Id, emp);

for (PAN_Card__c p : trigger.New) {
if (mapEmployee.containsKey(p.Employee__c)) {
p.addError(‘A PAN Card already exist for the employee – ‘ +
mapEmployee.get(p.Employee__c).Name);
}
}
}

70. Does trigger fire on Rollup summary change? YES
So, when the child record is saved and the field feeds into the
roll-up summary the parent trigger is executed.
71. Formulas ignore Field Level Security settings is it true?
Yes Formula field ignore FLS
72. What is data type of field when you save image in salesforce
object field?
Rich Text Area

73. What is screen visual flow? can we auto launched Screen Visual flow?
Flow Types
There are five different types of flows that are available in Salesforce.
Screen Flows – Screen Flows that have a UI element and require user
interaction because it input from users. These types of flows are either
launched as an action steps, choices, or dynamic choices.
Schedule-Triggered Flows – Schedule-Triggered Flows runs automatically
in the background at a specified time and frequency for each record
in a batch. It does not need user interaction.
Auto launched Flows (No Trigger) – Auto launched Flows (No Trigger)
doesn’t need user interaction. Autol aunched Flows launches when invoked
by supports Processes, custom apex classes, Rest API, web tabs,
custom button or custom links and visual force pages. This Auto launched
Flows runs in the background.
Record-Triggered Flows – Record trigger flow launches when a record is
created, updated or deleted. This Record-Triggered Flows runs in the
background
Platform Event-Triggered Flows – When a platform event message is received.
This Platform Event-Triggered Flows runs in the background.

74. What is difference between Workflow and Process builder?
Workflow:
Immediate calling workflow/
Time dependent workflow not for criteria = = created, and every time it’s edited
it has four major operation here .
Send Mail
Create Task
Update field
outbound message : end point url: Criteria: User Send By :
It is basically worked on single object.
Run in system Mode
Re-evaluate Workflow Rules after Field Change -> Execute Dependent workflow of field update on
same object

Process builder:
The Process start when
Record Change
A platform event occur
Its invoked by another process

Action:
Apex
Create Record
Update Record
Flow
Process
Email Alert
Post to chatter
Quick Action
Submit for approval

Used multiple object here.

It is basically worked on multiple objects. You can not send outbound message in Process builder
Process Builder runs in the system mode so the object and field level permissions both will be
ignored for the user who triggers the Process.

75. What is difference between Process builder and Visual flow ?
System mode: – In which the object and field-level permissions of the current user are ignored.
User mode: – In which the permissions, field-level security, and sharing rules of the current
user are enforced.
Flow runs in user mode.
Process Builder runs in system mode.
When you launch a Flow using the Process Builder, then it will run in system mode.

76. What is recursive workflow rule? How to avoid it? Taking one Boolean field check if true it
on WF after that set false

77. What is SOQL injection? How to avoid it? – Vulnerability
Static queries with bind variables
String.escapeSingleQuotes()
Type casting
Replacing characters
Whitelisting

78. Scenario based questions

show and hide three field on UI on the basis of picklist value change? by OOB – record type and
process builder and page Layout

Account and contact has check box my status field – when user change contact check box then
account check box will need to update? Process builder /trigger

When user click on custom button then new page will open. On that page you have another Button ,
on click of this button one popup(confirmation box) will open.
when user click on ok then current page should be closed and standard page should be open again?
Window.close(); window.parent.location. Cofirmation box.

Callout API from Batch class and passed success or error record toward third party application.
In Finish Method call API () and Database.SaveResult[] use to collect pass and fail record and
add to list or map.

79. How to exposed Apex rest API?
rest-api-integration-salesforce

@RestResource(urlmapping=’/getAllLead/’)
global with sharing class exposeMyApi
{
@httpGet//@httpPost//@httpDelete//@HttpPut//@HttpPatch
global static List<lead> getAllLead()
{ RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf(‘/’)+1);
Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId];
return result;
}
}

80. Continuation : Long running api callout from Visualforce page?
VF -> App Server -> Continuation server -> Internet -> Webservice
HttpRequest req=new HttpRequest();
req.setEndPoint();
req.setMethod();
req.setHeader();
req.setTimeout();
req.setBody();

Continuation con = new Continuation();
con.continuationMethod=”ProcessResponse”;
con.addHttpdRequest(req);

Public sObject ProcessResponse()
{
HttpResponse res=continuation.getResponse();
return res.getBody();
}

80. How to make Continuation Callout from Lightning Component?
public with sharing class SampleContinuationClass {
// Callout endpoint as a named credential URL
// or, as shown here, as the long-running service URL
private static final String LONG_RUNNING_SERVICE_URL =
‘<insert your callout URL here>’;

// Action method
@AuraEnabled(continuation=true cacheable=true)
public static Object startRequest() {
// Create continuation. Argument is timeout in seconds.
Continuation con = new Continuation(40);
// Set callback method
con.continuationMethod=’processResponse’;
// Set state
con.state=’Hello, World!’;
// Create callout request
HttpRequest req = new HttpRequest();
req.setMethod(‘GET’);
req.setEndpoint(LONG_RUNNING_SERVICE_URL);
// Add callout request to continuation
con.addHttpRequest(req);
// Return the continuation
return con;
}

// Callback method
@AuraEnabled(cacheable=true)
public static Object processResponse(List<String> labels, Object state) {
// Get the response by using the unique label
HttpResponse response = Continuation.getResponse(labels[0]);
// Set the result variable
String result = response.getBody();
return result;
}
}

81. How to exposed apex SOAP API?
global with sharing class MySoapWebService
{
webservice static Account getAccount() {
return [select Id,Name from Account limit 1];
}
}

82. what are type of exception in Apex?
AsyncException
DMLException CalloutException
EmailException
ExternalObjectException
QueryException
ListException
MathException
LimitException
InvalidParameteralueException
NoSuchElementException
NullPointerReferenceException
RequiredFeatureMissingException
NoDataFoundException
NoAccessException
SerachException
StringException
TypeException
XML
JSON
SerializationException
SecurityException
VisualforceException

—————-
getMessage()
getDMlMessage()
initcause()
getLineNumber();
getStackTtraceString();

83. what is future Method?
Asynchronous callback when resource will be available
Increase governor limit – 200 soql and 12 MB heap size
callout api – @future(callout=true)
method should be static
Parameter should be primitive datatype, arrays of primitive data types, or collections of
primitive data types
return type should be Void
API call out from trigger @future(callout=true)
can not call from VF controller
can not call from future method
can not call from batch Apex
50 future method in one transaction

you can not perform DML before Future method execution

Mixed DML error occur when you perform DML in setup object and std/Custom object in same transaction.
To avoid Mixed DML error use future method to do DML on setup object (User,UserRole,Permission set)

84. What are sharing setting inn salesforce?
Sharing Record by following ways?
Profile – Limited users
Role Heirarchy
Setup->ManageUser->role->Setup role->click on add role->provide name and save
OWD : Grant Hierarchy Access for Role Works
Define base line setting of orgnization all users
Private
Public read only
Public read write
Public read/write/transfer (case and lead)
Public full access(campaign)
View only/No access/ Use (price book)
Control by Parent

OWD Profile(CRED/VM)   Result
Private  CRED               My Records (Read/Write)
Private       CR                 My Records (Read)
Private       —       No Access
Public Read Only     CRED               My Records(Read/Edit), Others Records(read)
Public Read Only     CR                 My Records(Read), Others Records(read)
Public Read Only     —                  No Access
Public Read/Write    —                  No Access
Public Read/Write    CRED               My Records(Read/Edit), Others Records(read/write)
Public Read/Write    R                  My Records(Read), Others Records(read)
Public Read Only     R                  My Records(Read), Others Records(read)
Public Read Only     CRED/View All      My Records(Read/Edit), Others Records(read)
Public Read/Write    CRED/View All      Read/Edit All Records
Private       CRED/View All      My Records(Read/Edit), Others Records(read)
Public Read/Write  CR/View All        My Records(Read), Others Records(read)
Public Read Only  CR/View All        My Records(Read), Others Records(read)
Public Read Only  Modify All         My Records(Read/Edit), Others Records(read/Edit)
Public Read/Write  Modify All         My Records(Read/Edit), Others Records(read/Edit)
Private    Modify All         My Records(Read/Edit), Others Records(read/Edit)


Manual Sharing
Apex sharing
Criteria based sharing rule
Owner Based sharing Rule
Guest User Access Criteria based sharing rule

85. how to create Parent and Child Records in a Single DML Statement?

Create MyExtID__c text field and mark it as external Id field on Account object.

public class ParentChildSample {
public static void InsertParentChild() {
Date dt = Date.today();
dt = dt.addDays(7);

Opportunity newOpportunity = new Opportunity(
Name=’OpportunityWithAccountInsert’,
StageName=’Prospecting’,
CloseDate=dt);

// Create the parent reference.
// Used only for foreign key reference
// and doesn’t contain any other fields.
Account accountReference = new Account(
MyExtID__c=’SAP111111′);
newOpportunity.Account = accountReference;

// Create the Account object to insert.
// Same as above but has Name field.
// Used for the insert.
Account parentAccount = new Account(
Name=’Hallie’,
MyExtID__c=’SAP111111′);

// Create the account and the opportunity.
Database.SaveResult[] results = Database.insert(new SObject[] {
parentAccount, newOpportunity });

// Check results.
for (Integer i = 0; i < results.size(); i++) {
if (results[i].isSuccess()) {
System.debug(‘Successfully created ID: ‘
+ results[i].getId());
} else {
System.debug(‘Error: could not create sobject ‘
+ ‘for array element ‘ + i + ‘.’);
System.debug(‘ The error reported was: ‘
+ results[i].getErrors()[0].getMessage() + ‘\n’);
}
}
}
}

86. Contact count shown on account object using trigger?
go to below blog.
http://avideep.com/total-number-of-contact-count-shown-on-account-object-using-apex-trigger/
Trigger for Roll up summary
I want to write a trigger on Contact ,Account object is having a field named Count__c .
I want to autopopulate the nos of
Contacts associated with that Account.

87. How to send birthday email?
Send an automatic birthday email to Contacts via Workflow Rules/Apex Batch job

88. How to convert List into JSON?

Json.serialize(list);

89. How to Convert JSON string into Map?
Map<String,Object>)JSON.deserializeUntyped(req.RequestBody().toString());
responeWrapper wrapObj= (responeWrapper)
JSON.deserialize(req.requestbody.toString(),responeWrapper.class);

90. How to convert Custom label Json data into map?
Map< String, String> mapOfEmailLabel = (Map<String,String
>)JSON.deserialize(System.label.EmailHandlerLabels, Map< String,String> .class);

91. What is Dynamic Apex: Schema Describe , Dynamic SOQL, Dynamic SOSL,Dynamic DML, Schema Class?
//Schema.getGlobalDescribe().get(objName).getDescribe().fields.getMap().get(fieldName).
getDescribe().getLabel();

The following are methods for Schema. All methods are static.
getGlobalDescribe()
Returns a map of all sObject names (keys) to sObject tokens (values) for the standard and custom
objects defined in your organization.

describeDataCategoryGroups(List<String>)
Returns a list of the category groups associated with the specified objects.

describeSObjects(List<String>)
Describes metadata (field list and object properties) for the specified sObject or array of
sObjects.

describeTabs()
Returns information about the standard and custom apps available to the running user.

describeDataCategoryGroupStructures(List<Schema.DataCategoryGroupSobjectTypePair>)
Returns available category groups along with their data category structure for objects specified
in the request.
string objectfullname = ‘scenario__c’;
Schema.SObjectType targetType = Schema.getGlobalDescribe().get(‘scenario__c’);
if (targetType == null) {
system.debug(‘Type not found: ‘+objectFullname);
throw new EpgwController.TypeNotFoundException(objectFullName);
}
Schema.DescribeSObjectResult typedescription = targetType.getDescribe();
Map<String, schema.Sobjectfield> resultMap = typedescription.Fields.getMap();
string query = ‘SELECT ‘ + string.join(new List<string>(typedescription.Fields.getMap().keySet()), ‘,’) + ‘ FROM ‘+ objectfullname + ‘ LIMIT 100’;
sobject [] records = Database.query(query);

Dynamic SOQL:

String myTestString = ‘TestName’;
List<sObject> sobjList = Database.query(‘SELECT Id FROM MyCustomObject__c WHERE Name =
:myTestString’);

MyCustomObject__c myVariable = new MyCustomObject__c(field1__c =’TestField’);
//List<sObject> sobjList = Database.query(‘SELECT Id FROM MyCustomObject__c WHERE field1__c =
:myVariable.field1__c’); Not Support

String resolvedField1 = myVariable.field1__c;
List<sObject> sobjList = Database.query(‘SELECT Id FROM MyCustomObject__c WHERE field1__c = :resolvedField1’);

Dynamic SOSL:

List<List <sObject>> myQuery = search.query(SOSL_search_string);

String searchquery=’FIND\’Edge*\’IN ALL FIELDS RETURNING Account(id,name),Contact, Lead’;
List<List<SObject>>searchList=search.query(searchquery);

92. How to dynamically instantiate object?
public class DynamicSObjectCreation {
public static sObject createObject(String typeName) {
Schema.SObjectType targetType = Schema.getGlobalDescribe().get(typeName);
if (targetType == null) {
// throw an exception
}
// Instantiate an sObject with the type passed in as an argument
// at run time.
return targetType.newSObject();
}
}

93. how to dynamically get field in apex?
for(String str: Schema.getGlobalDescribe().get(‘Account’).getDescribe().fields.getMap().keySet())
system.debug(‘==’+Schema.getGlobalDescribe().get(‘Account’).getDescribe().fields.getMap().get(str));

94. How to get Picklist value without SOQL?
String objectName = ‘Contact’;
String fieldName =’LeadSource’;
Schema.SObjectType s = Schema.getGlobalDescribe().get(objectName) ;
Schema.DescribeSObjectResult r = s.getDescribe() ;
Map<String,Schema.SObjectField> fields = r.fields.getMap() ;
Schema.DescribeFieldResult fieldResult = fields.get(fieldName).getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

for( Schema.PicklistEntry pickListVal : ple){
System.debug(pickListVal.getLabel() +’ ‘+pickListVal.getValue());
}

95. What is significant of with sharing and without sharing in apex? What is default?
Default – Without Sharing – system mode.
With Sharing – Invoke sharing rule and FLS
Without Sharing – Not invoke sharing rule, setting and FLS.

96. How to Get Current User information in apex?
UserInfo.getUserId(),getUserName(),getUserRoleId(),getUserEmail(),getLocale(),getProfileId()
getDefaultCurrency(),getFirstName(),getLastName(),getName(),getTimeZone()

97. Why there is no before-undelete event in Salesforce triggers?
Because, there will be no record available before Undelete to update. But After Undelete you will be having a record to update something with that record.

98. What is wrapper class and how you will practically used it?
it is collection of object instance. Wrapper class is useful to create 360 degree view page.

99. Which are email templates in salesforce?
Custom template, Html Template, Text Template, Visualforce Template

100. What is difference Between Put and Post in rest API callout?
POST – Insert – ALL or None
PUT – Update Insert- PARTIAL DML

101. CPU time Limit exception handling in Apex ?
use more optimized loops
use bulkified triggers patterns
move some logic to future methods
avoid nested loops where it is possible
move aggregation to SOQL where it’s possible

102. What is Page Variation in Community?
Page variations let you quickly create alternative versions of a page. Try out different page
layouts and styles or create variations aimed at specific audience.
You can start with a blank page variation or duplicate an existing one to jump-start the
process.Manage Audiance

103. what are License in communities?
Lightning External Apps Starter
Customer Community
Customer Community Plus
Partner Community
Partner Community Plus
Lightning External Apps Plus

104. Salesforce Identity?
Single sign-on
Connected apps
Social sign-on
Two-factor authentication
MFA (Multi Factor Authentication) In Salesforce
My Domain
Centralized user account management
User provisioning
Identity Connect
App Launcher

105.Difference between future and queueable?
You can not pass object as parameter in future method, but you can in queueable.
you can not call future method from future method, but you can in queueable.
you can monitor queueable method.

106. is apex rest API is in system mode or User mode? => system mode

107. What is lifecycle of Lightning component – 
Lifecycle as below:

108. what is bound and unbound expression in lightning? {!v.attr} and {#v.attr}

109. What is Use of THIS in style? Top level element consider

110. How many way you can do communication between component in Lightning?
Event(Application and component), Aura Method, Attribute

111. What are best practice to follow in lightning increase performance?
1.Avoid Server Trips
2.Use Storable Action
var action = component.get(“c.getItems”);
action.setStorable();
action.setCallback(this, function(response) {
// handle response
};
$A.enqueueAction(action);

2.Use Lightning Data Service
4.Lazy Instantiation of Component
5.Conditional rendering
Using CSS
Using aura:if(Recommended. element not create till to condition true)
6.Use of Unbound Expression
Bi-directional binding : {!v.var1}
Unidirectional or unbound expression  {#v.var1}
7.Use aura:method for Component Communications
8.Limit event handlers
9.Limit use of Application event
10.Limit use of Javascript Libraries
11.Use of Lightning Base Components
12.Debug mode off in Production

112. What design pattern you use in Apex?
Singleton, strategy, Facade,Decorator,Composite, bulk state transition

113.What are points to have check in code review. 
avoid SOQL inside for loop,
avoid dynamic soql,
use static soql with bind variable,
avoid for loop inside for loop,
use future method where necessary,
use custom label and custom setting,
metdata for dynamic change
check number of trigger on object,
use map instead of list.

114. What are interface use in lightning component. and what are significance of that?
Lightning component namespaces.
Lightning component interfaces.
So let’s begin,

Lightning Interfaces uses to allow a component to be used in different contexts, or to enable
your Lightning component to receive extra context data. A Lightning component can use multiple
interfaces. Interfaces that user in component have an effect only in Lightning Experience and the Salesforce app.

Lightning Component interfaces belong to different namespaces, including:

clients: This namespace provides interfaces that are specific to the Outlook integration or
Lightning for Gmail.
flexipage: This namespace provides interfaces that are specific to Lightning Pages and the
Lightning App Builder.
force: This namespace provides interfaces that are specific to Lightning Experience and the
Salesforce app.
forceCommunity: This namespace provides interfaces that are specific to Communities.
lightning: This namespace provides interfaces that are specific to Lightning Experience, the
Salesforce app, and Communities.
ltng: This namespace provides events that are handled by Lightning Out.
Some of these interfaces from above namespace are summarized below.
1. clients:availableForMailAppAppPage – This interface use to appear component in Lightning
App builder or a Lightning Page in Outlook integration or Lightning for Gmail.
2. clients:hasEventContext – Use to enable a component to be assigned to an event’s date or
location attributes in Outlook integration and Lightning for Gmail.
3. clients:hasItemContext – Use to enable a component to be assigned to an email’s or a
calendar event’s item attribute in Outlook integration and Lightning for Gmail.
4. ltng:allowGuestAccess – Using this interface in your Lightning Out dependency app,
available to users without requiring them to authenticate with Salesforce. This interface lets
you deploy your app with lightning component anywhere and to anyone.
5. flexipage:availableForAllPageTypes – It’s a global interface that available component in
the Lightning App builder, and for any types of Lightning page.
Note: To make a component available for utility bar flexipage:availableForAllPageTypes interface
must be used in your component.
6. flexipage:availableForRecordHome – Make your Lightning component available for record
pages.
7. forceCommunity:availableForAllPageTypes – Make your Lightning component available for
Community Builder.
8. force:appHostable – Make a component to be used as a custom tab in Lightning Experience or
the Salesforce app.
9. force: lightningQuickAction – This interface make your component available for display in
a panel with standard action controls, such as a Cancel button. By using this interface
component can also display and implement their own controls, but should handle events from the
standard controls.
Note: If you implement force: lightningQuickAction in your component, you can’t implement force:
lightningQuickActionWithoutHeader within the same component.
10. force: lightningQuickActionWithoutHeader – Make your component to display in a panel
without additional controls. Your component should provide a complete user interface for the
action.
Note: If you implement force: lightningQuickActionWithoutHeader in your component, you can’t
implement force: lightningQuickAction within the same component.

115. what is LWC and benefit over Lightning Component?
Benefits of Lightning Web component (LWC) over Aura Lightning Component (ALC)

Site Loading Speed:
The Lightning web component is hugely faster than the Aura component in loading web pages.

Easy Learning:
The Lightning web component script uses HTML & Javascript language. That means tasks are more
comfortable to do.

Best performance:
As LWC builts on web components, It makes LWC extremely lightweight & efficient in memory
management. That’s the reason LWC runs much faster than Aura lightning components.

Debugging made easy:
Debugging is significantly easier for LWC than ALC. Different Salesforce discussion forums
address & execute the step by step debugging topics very quickly.

Easy to ramp:
The absence of a different framework enables developers to learn LWC more easily.

Standardized:
As LWC uses core web components, it offers everything needed for the blazing-fast performance of
browsers. It uses common coding languages like CSS, Javascript & HTML.

Inbuilt browser security features:
LWC has inbuilt browser security features driving its out-of-the-box usage while Aura requires
an event-driven programming model that is GUI dependent.

It focuses on actions like button press & clicks determining the flow of movement. The Lightning
web components support these actions.

Data binding:
Data binding is a technique that binds data sources from the provider and consumer together and
synchronizes them.

LWC supports two-way data binding that helps in coordinating how data moves between different
components.

Unit testing Support:
LWC supports the unit testing framework.

Versatility:
Full encapsulation is available with LWC.

116. Read All about API. Rest API, SOAP API, BULK API, Chatter API, Streaming API, Metadata API,
APEX REST API, APEX SOAP API.
Platform Events
Integration best practice
Integration Pattern
Integration Security

117. What is Salesforce shield?
Salesforce Shield is a trio of security tools that helps admins and developers build extra
levels of trust, compliance, and governance right into business-critical apps. It includes
Shield Platform Encryption, Event Monitoring, and Field Audit Trail. Ask your Salesforce
administrator if Salesforce Shield is available in your organization.

Shield Platform Encryption: allows you to natively encrypt your most sensitive data at rest
across all your Salesforce apps.

Real-Time Event Monitoring: gives you access to detailed performance, security, and usage data
on all your Salesforce apps. See who is accessing critical business data when, and from where.

Field Audit Trail: lets you know the state and value of your data for any date, at any time. You
can use it for regulatory compliance, internal governance, audit, or customer service.

118. code review best practice – PMD – programming mistake detector

119. How to change owner of record.
public without sharing class noSharing {
public static void changeOwner(Account acc, User us){
acc.OwnerId = us.Id;
update acc;
}
}

120. What are new features are introduced in salesforce?
Manual sharing button in lightning
Salesforce Release Notes Moving to Salesforce Help. …
Manually Share Records in Lightning. …
Images and Snooze Options in In-App Guidance. …
Customizable Actions on Recently Viewed List Views. …
Customize the No-Reply Email Address for Certain Email Notifications

121. What are the things need to consider at the time of Apex Rest API Consumed and Exposed.
Integration Pattern

122. How to pass Values/parameter from Visual force page to Lightning Component? (By Using
Application Event)
Create Lightning out App to call the lighting component from the visualforce page. add your
component in lightning out App. Create Visualforce page and include <apex:includeLightning /> in
page.

1. Firing Events from the Visualforce and Handling the Events in lightning components
To demonstrate this ,lets create a simple event file and fire the event from the visualforce
inside the callback and handle the event back in the lightning component file
Below is the component set up for lightning framework

<aura:application access=”GLOBAL” extends=”ltng:outApp”>
<aura:dependency resource=”c:sampleComponent” />
</aura:application>
<aura:component>
<div>
Hello world Component!
</div>
<aura:handler event=”c:sampleEvent” action=”{!c.handleevent}”/>
</aura:component>
({
handleevent: function(component, event, helper) {
console.log(‘event fired’);
}
})

<aura:event type=”APPLICATION”>
</aura:event>
<apex:page showHeader=”true” sidebar=”true”>
<apex:includeLightning />
<div id=”lightning”> hello World VF!! </div>
<script>
$Lightning.use(“c:sampleApp”, function() {
          $Lightning.createComponent(“c:sampleComponent”, {},
             “lightning”,
              function(cmp) {
                  var myExternalEvent;
                    myExternalEvent = $A.get(“e.c:sampleEvent”);
                    myExternalEvent.fire();
            });
});
</script>
</apex:page>

123. How to keep only Unique Value in javascript array?
<script>
var array = [“Manish”, “Chandan”, “Piyush”,
“Sunil”, “Pankaj”, “Piyush”,
“Pankaj”, “Tiny”, “Chandan”,
“Manish”];
var outputArray = [];
// Count variable is used to add the
// new unique value only once in the
// outputArray.
var count = 0;
// Start variable is used to set true
// if a repeated duplicate value is
// encontered in the output array.
var start = false;

for (j = 0; j < array.length; j++) {
for (k = 0; k < outputArray.length; k++) {
if ( array[j] == outputArray[k] ) {
start = true;
}
}
count++;
if (count == 1 && start == false) {
outputArray.push(array[j]);
}
start = false;
count = 0;
}
document.write(outputArray);
</script>

124. What are GIT command using in CI/CD process?
All GIT Command:
git clone ‘url’
git checkout ‘branchname’
git status
git add .
git commit -m ‘comments’
git push origin ‘branchname’
How to revert changes from Repository by using GIT
git reset –hard c1234fa
git fetch
git pull

125. How to enforce FLS in SOQL ?
List<Account> act1 = [SELECT Id, (SELECT LastName FROM Contacts),
(SELECT Description FROM Opportunities)
FROM Account WITH SECURITY_ENFORCED]

List<Account> act2 = [SELECT Id, parent.Name, parent.Website
FROM Account WITH SECURITY_ENFORCED]

List<AggregateResult> agr1 = [SELECT GROUPING(Type)
FROM Opportunity WITH SECURITY_ENFORCED
GROUP BY Type] 

126. What are SOQL like Select * from ?
Select FIELDS(ALL) From Account limit 200;
Select FIELDS(CUSTOM) From Account limit 200;
Select FIELDS(STANDARD) From Account limit 200;

FIELDS(ALL) —to select all fields of an object.
FIELDS(CUSTOM) — to select all custom fields of an object.
FIELDS(STANDARD) — to select all standard fields of an object.

127. What is a Change Data Capture event?
A Change Data Capture event, or change event, is a notification that Salesforce sends when a
change to a Salesforce record occurs as part of a create, update, delete, or undelete operation.
The notification includes all new and changed fields, and header fields that contain
information about the change. For example, header fields indicate the type of change that
triggered the event and the origin of the change. Change events support all custom objects and
a subset of standard objects.

When to use Change Data Capture:

Receive notifications of Salesforce record changes, including create, update, delete, and
undelete operations.
Capture field changes for all records.
Get broad access to all data regardless of sharing rules.
Get information about the change in the event header, such as the origin of the change, which
allows ignoring changes that your client generates.
Perform data updates using transaction boundaries.
Use a versioned event schema.
Subscribe to mass changes in a scalable way.
Get access to retained events for up to three days.
Subscribe to Change Event Channel:
Salesforce offers multiple ways to subscribe to a change event channel. For external application
to Salesforce, we can use Streaming API, or tools and libraries based on CometD, an open-source
library that simulates push technology. Streaming API provides a subscription mechanism based
on CometD.
To process data changes in Salesforce, we can write an Apex trigger for the change event. Change
event triggers are called as Asynchronous Apex Trigger.

Example:
To get change notifications, we have to enable Change Data Capture for the required object. Here
I have enabled the Lead Object Change Data Capture, for Change Notifications to listen to Lead
record changes.
Go to Setup | Enter Change Data Capture in the Quick Find box, and click Change Data Capture |
In Available Entities, select Lead object and click the > arrow |

Click Save.

128. What is deterministic and non deterministic in formula fields?
Formula field can also be indexed.

Here are examples of common non-deterministic formulas. Force.com cannot index fields that:

Reference other entities (i.e., fields accessible through lookup fields)
Include other formula fields that span over other entities
Use dynamic date and time functions (e.g., TODAY, NOW)
A formula is also considered non-deterministic when it includes:
Owner, autonumber, divisions, or audit fields (except for CreatedDate and CreatedByID fields)
References to fields that Force.com cannot index
Multi-select picklists
Currency fields in a multicurrency organization
Long text area fields
Binary fields (blob, file, or encrypted text)
Standard fields with special functionalities
Opportunity: Amount, TotalOpportunityQuantity, ExpectedRevenue, IsClosed, IsWon
Case: ClosedDate, IsClosed
Product: Product Family, IsActive, IsArchived
Solution: Status
Lead: Status
Activity: Subject, TaskStatus, TaskPriority

Also in Working with Very Large SOQL Queries – Custom Index Considerations for Selective SOQL
Queries
A custom index can’t be created on these types of fields: multi-select picklists, currency
fields in a multicurrency organization, long text fields, some formula fields, and binary fields
(fields of type blob, file, or encrypted text.) New data types, typically complex ones, are
periodically added to Salesforce, and fields of these types don’t always allow custom indexing.
You can’t create custom indexes on formula fields that include invocations of the TEXT function
on picklist fields.

129. Use case of pricebook object in salesforce ?
“A price book is a list of products and their associated prices. Each product and its price is
called a price book entry” as defined by Salesforce.com. When you combine price books and
products, you are able to see the various products your company can provide along with the
prices of the products.
Pricebooks
A pricebook is a list of products and their associated prices. Each product and its price is
called a pricebook entry. The price book will provide a list of the products and the different
prices for the products. Salesforce will provide standard and custom price books, making it
easy to have multiple prices for a product.
In other words we can say that sometimes your prices for products will differ per customer – it
can depend on who is buying, when they are buying, or in what quantity. To accommodate this
flexibility, a Product can exist in Salesforce with many different associated prices, using a
feature called Price Books and Price Book Entries.
A Product can exist in multiple Price Books, for every different price on offer to a customer.
The combination of the Product and the price together is what we call a Price Book Entry. Price
book is divided into two parts:
1. Standard Price Book:
The Standard Price Book is the full list (i.e. the master list) of all the products and services
your company sells. It is already present and new products can be added to it using the related
list present at the product’s detail page.
2. Custom Price Book:
These are additional pricebooks created as per the requirements of the company. The price for
each Product in the Custom Price Book may be different from the price in the Standard Price
Books. The price for the same Product in each Custom Pricebooks does not need to be the same –
it can vary from one Custom Price Book to another.

130. What are Integration Pattern ?
Remote Process Invocation—Request and Reply : Salesforce invokes a process on a remote system,
waits for completion of that process, and then tracks state based on the response from the
remote system.
External Services : Point & click based integration from Lightning Flow. External system should
provide OpenAPI or Interagent schema. Only supports primitive datatypes

LWC or Visualforce calling external system : Salesforce enables you to consume WSDL and generate
proxy classes. It also provides HTTP services using which we can perform GET, POST, PUT or
Delete operations. A user can initiate operation from custom UI.

Trigger : We can make callout to external system on data change via trigger. However callout
made must be asynchronous. This solution is not recommended for request and reply but better
suited for Fire and Forget.

Batch Apex invoking external services : We can make callout to external system using Batch Apex.
Execute method in Batch apex gets refresh governor limit every time however there are governor
limits on total callout or time of callout in single transaction

Remote Process Invocation—Fire and Forget : Salesforce invokes a process in a remote system but
doesn’t wait for completion of the process. Instead, the remote process receives and
acknowledges the request and then hands off control back to Salesforce.
Process-driven platform events
Customization-driven platform events
Workflow-driven outbound message
Apex based Callouts
Trigger based Callout

Batch Data Synchronization : Data stored in Lightning Platform is created or refreshed to
reflect updates from an external system, and when changes from Lightning Platform are sent to an
external system. Updates in either direction are done in a batch manner.
Change Data Capture : Salesforce publishes change events, which represents changes on records
Using ETL Tool : This tool connects to systems, extract data, transform in require target format
and uploads using Bulk API or SOAP API
Manual Remote Calls : Salesforce or external system can call each other every time data is
changed. However, it would cause huge ongoing traffic and should be avoided if possible

Remote Call-In : Data stored in Lightning Platform is created, retrieved, updated, or deleted by
a remote system.
SOAP & Rest API
Apex based APIs

UI Update Based on Data Changes : The Salesforce user interface must be automatically updated as
a result of changes to Salesforce data.

Data Virtualization : Salesforce accesses external data in real time. This removes the need to
persist data in Salesforce and then reconcile the data between Salesforce and the external system.

131. What are Common Design Patterns ?
Singleton – minimizing object instantiation for improved performance and to mitigate impact of
governor limits
Strategy – defining a family of algorithms, enscapsulating each one and making them
interchangeable and selectable at runtime
Decorator – extending the functionality of an sObject in Apex
Facade – simplifying the execution of classes with complex interfaces (e.g. web service
callouts)
Composite – treating a group of objects in a similar manner to a single instance of that object
Bulk State Transition – efficiently tracking the change of a field value in a trigger and
executing functionality based on this change

132. What are field data type and their significance in salesforce custom objects.
Auto Number
: A system-generated sequence number that uses a display format you define. The
number is automatically incremented for each new record.
Formula : A read-only field that derives its value from a formula expression you define. The
formula field is updated when any of the source fields change.
Roll-Up Summary :
A read-only field that displays the sum, minimum, or maximum value of a field in a related list
or the record count of all records listed in a related list.
Lookup Relationship: Creates a relationship that links this object to another object. The
relationship field allows users to click on a lookup icon to select a value from a popup list.
The other object is the source of the values in the list.
Master-Detail Relationship: Creates a special type of parent-child relationship between this
object (the child, or “detail”) and another object (the parent, or “master”) where:
The relationship field is required on all detail records.
The ownership and sharing of a detail record are determined by the master record.
When a user deletes the master record, all detail records are deleted.
You can create rollup summary fields on the master record to summarize the detail records.
The relationship field allows users to click on a lookup icon to select a value from a popup
list. The master object is the source of the values in the list.
External Lookup Relationship : Creates a relationship that links this object to an external
object whose data is stored outside the Salesforce org.
Checkbox: Allows users to select a True (checked) or False (unchecked) value.
Currency: Allows users to enter a dollar or other currency amount and automatically formats the
field as a currency amount. This can be useful if you export data to Excel or another
spreadsheet.
Date: Allows users to enter a date or pick a date from a popup calendar.
Date/Time: Allows users to enter a date and time, or pick a date from a popup calendar. When
users click a date in the pop-up, that date and the current time are entered into the Date/Time
field.
Email: Allows users to enter an email address, which is validated to ensure proper format. If
this field is specified for a contact or lead, users can choose the address when clicking Send
an Email. Note that custom email addresses cannot be used for mass emails.
Geolocation : Allows users to define locations. Includes latitude and longitude components, and
can be used to calculate distance.

Number: Allows users to enter any number. Leading zeros are removed.
Percent: Allows users to enter a percentage number, for example, ’10’ and automatically adds the
percent sign to the number.
Phone: Allows users to enter any phone number. Automatically formats it as a phone number.
Picklist: Allows users to select a value from a list you define.
Picklist: (Multi-Select) Allows users to select multiple values from a list you define.
Text: Allows users to enter any combination of letters and numbers.
Text Area: Allows users to enter up to 255 characters on separate lines.
Text Area (Long): Allows users to enter up to 131,072 characters on separate lines.
Text Area (Rich): Allows users to enter formatted text, add images and links. Up to 131,072
characters on separate lines.

Text (Encrypted) :Allows users to enter any combination of letters and numbers and store them in
encrypted form.
Time: Allows users to enter a local time. For example, “2:40 PM”, “14:40”, “14:40:00”, and
“14:40:50.600” are all valid times for this field.
URL: Allows users to enter any valid website address. When users click on the field, the URL
will open in a separate browser window.

132. What is cross object formula field?

 

133. Whenever a case is created with origin as Phone’ then set status as New’ and Priority as High.

Answer: Object: Case

Trigger: Before insert

Code:

1
2
3
4
5
6
7
8
trigger CaseOrigin on Case (before insert) {
 for(case c : trigger.new){
     if(c.origin == 'Phone'){
          c.status = 'New';
          c.priority = ’High’;
         }
     }
}

134Whenever Lead is created with LeadSource as Local then give rating as cold otherwise hot.

1
2
3
4
5
6
7
8
9
10
11
trigger LeadScenario on Lead (before insert) {
for(lead ld : trigger.new){
if(ld.leadsource == ‘Local’)
 {
  ld.Rating = 'Cold';
 }
else{
ld.Rating = 'Hot';
   }
 }
}

135. Is Test.startTest() and Test.stopTest() required in a test class?

Answer: Test.startTest() and Test.stopTest() exist primarily to allow you to reset the governor limits within the context of your test execution and to be able to test asynchronous methods. These two statements cannot be called more than once within a testMethod. They are not required to be used but in some situations may be critical. 

136. Let say a user does not have permission on a child object and is having permission on parent object to read/create/edit/delete parent object, If there is a trigger on parent object to insert a child record after parent record is created, will it create a child record or not after the user insert parent record manually?

Answer: Yes, a child record will be created.

137. You are having a requirement to pass value from child component to parent component which type of event you will use?

Answer: Component events are used in cases where there is a relationship between two components. Component Events are fired by the child components and handled by the parent component.

138. Suppose we have a requirement to create an account using a new button and some default values in the new account screen. How can we achieve this requirement?

Answer: We can make use of force:createRecord; it is an event that opens a page to create a record for a specific entity. 

Sample syntax:

1
2
3
4
5
6
7
createRecord : function (component, event, helper) {
    var createRecordEvent = $A.get("e.force:createRecord");
    createRecordEvent.setParams({
        "entityApiName": "ObjectApiName"
    });
    createRecordEvent.fire();
}

139. There is a profile by name ReadAccessProfile’ and two users User1 and User2 have been assigned to it. There is an object X. I want to have ReadWrite access for User1 and ReadOnly access for User2 for the object X. How can this be accomplished?

  1. Step 1: Read Access for both users is common hence in the Profile settings give ‘Read’ access for the object ‘X’. By doing this User U2 will be able to read all the records( One condition satisfied) but User1 will only be able to read the records (Second condition not satisfied).
  2. Step 2: So next what we do is we create a permission set say ‘GrantWriteAccess’ and in this permission set we give the object ‘X’ the Write access and assign the user User1 to this permission set. (Second condition satisfied).

140. I have two objects Object1 and Object2 which are not related to each other. Now I want to create a Master Detail Relationship(MDR) between these objects. How can I do this?

Answer: Scenario 1: If the two objects are new and there are no records in each. Then we can create a Master-detail relationship by creating the field in Setup.

Scenario 2: If the two objects exist prior to this requirement and have records . If this is the scenario then we should first create a lookup relationship between the two objects and make sure that all the values are filled and then convert the relationship to master-detail from lookup.

141. The requirement is to delete a set of records and dont want them to be stored in the recycle bin as well. What are my options?

Answer: This can be done using the Hard Delete option. It can be done in apex by calling emptyRecycleBin().

142. In the before Insert event trigger which context variable is correct Trigger.new or new Trigger.newmap?

Answer: As the event is before insert only trigger.new will be supported.

Trigger.newmap will not be supported as we do not have an id of record before the record is inserted.

143. What is the difference between profile and role? Can a user be assigned two profiles ?

Answer: A Salesforce profile controls the following key aspects pertaining to    Salesforce:

  • Field Level Security – Here, the users are restricted to create, read, edit, and delete fields according to specific requirements.
  • Page Layouts – This restricts the page layouts a Salesforce user is permitted to see.
  • Custom Apps – This restricts all the custom and standard apps that can be viewed and accessed by a Salesforce user.
  • Record Types – This restricts the record types available to specific Salesforce users.
  • Login – This restricts the login hours of Salesforce users onto the platform based on specific requirements.
  • Tabs – This restricts the tabs that can be accessed and viewed by the Salesforce users.

There are two major types of user-profiles in Salesforce – standard profiles and custom profiles. While a standard profile is already provided by Salesforce, a custom profile can be created by the users based on their specific requirements.

144. What are governor limits in Salesforce?

Answer:  As we all know, Salesforce is on a shared (multi-tenant) platform which means the whole resource is shared with everyone who is a client/customer of Salesforce. This requires Salesforce to enforce some limits of the resource used by each client/customer. These rules are referred to as Governor Limits. These limits are different according to the license or version the client/customer has purchased/ subscribed to. 

The governor rules limit:

  1. Per-Transaction Apex Limits
  2. Per-Transaction Certified Managed Package Limits
  3. Force.com Lightning Platform Apex Limits
  4. Static Apex Limits
  5. Size-Specific Apex Limits
  6. Inbound Email Limit
  7. SOQL and SOSL Governor Limits in Salesforce
  8.  Notification Push Limit
  9. Api request limits

145. Can you edit an apex trigger/ apex class in the production environment? Can you edit a Visualforce page in the production environment?

Answer: No, you cannot edit and apex trigger or class in production. You need to make the changes in the dev environment and then deploy it using the deployment tools.

146. What is a sandbox and what are the different types of sandboxes?

Answer:

A sandbox serves as a copy of the production environment where the developers and testers can create and test new features and configuration changes without affecting the data or settings of the production environment.

There are 4 types of sandboxes:

  1. Developer (200MB storage, refreshes daily, Used for developing)
  2. Developer Pro (1GB storage, refreshes daily, Used for integration testing)
  3. Partial Copy (5GB storage, refreshes every 5 days, Used for end-end test)
  4. Full (Same size as Production, refreshes in 28 days, Used for UAT testing)

147. What is a standard profile and name some of them?

Answer: A standard profile is a profile assigned to the users by Salesforce. These profiles cannot be deleted and need to adhere to the Salesforce permission sets assigned to them.

Some of the major standard profiles are:

  1. System Administrator
  2. Standard User
  3. Marketing User
  4. Solution Manager
  5. Read only
  6. Contract Manager

148. What are the different types of relationships in Salesforce ? Can you differentiate between them?

Answer: Relationships depict how two objects are related to each other. Salesforce allows the following relationships:

  1. Master-detail relationship
  2. Lookup relationship
  3. Many to many relationship
  4. Self relationship
  5. External relationship

Master-detail relationship: In this relationship one object acts as the master or controlling object and the other object acts as the detail or the controlled field. When the master object record is deleted the detail records get deleted along with it.

The master record is required on the detail record. It is a tightly bound relationship. We can only assign two master-detail relationships per object. We can only create a roll-up summary field on this relationship.

Lookup relationship: In this relationship the objects are loosely coupled. The object doesn’t get deleted if the other object is deleted.Parent and child records have their own sharing and security settings. The lookup relationship is not mandatory by default. We can assign upto 40 lookup relationships per object.

Many to many relationships:  There is no such relationship such as many to many  but we can create it by adding two master-detail relationships to a common object. The common object is also known as Junction object.

Self Relationships: A self relationship is a relationship with the same object. This can be explained better with an example: A account is related to a parent account.

External Relationships: It is a new relationship which was introduced with Salesforce Connect. We use this relationship to link an external object to another external object. It supports Standard lookup relationships that uses 18 characters Salesforce Id for the association.

149. What is SOQL and SOSL? What are the differences?

Answer: SOQL (Salesforce Object Query Language) are used to construct simple and powerful query strings in the queryString parameter in the query() call, in Apex statements, triggers, in Visualforce controllers and getter methods, or in the Schema Explorer of the Force.com IDE. It is similar to SQL with features to query Salesforce objects directly. It can only search one object at a time. It returns records on which DML operations can be performed

SOSL ( Salesforce Object Search Language)  is used to construct text searches in the search() call, in Apex statements, in Visualforce controllers and getter methods, or the Schema Explorer of the Eclipse Toolkit. It can be used to search multiple objects at one time. It cannot be used in triggers. It returns fields as results. DML operations cannot be performed on these results.

150. What is the difference between permission sets and sharing rules?

Answer: A Permission set is a collection of settings and permissions that give users access to various tools and functions. Permission sets extend users’ functional access without changing their profiles.

Sharing rules are used to extend sharing access to users in public groups, roles, or territories. Sharing rules give particular users greater access by making automatic exceptions to your org-wide sharing settings.

151. What are the different ways to deploy to production?

Answer:  The different ways to deploy to production are:

  1. Change Sets
  2. Eclipse with Force.com IDE ( Deprecated)
  3. Force.com Migration Tool – ANT/Java based
  4. Salesforce Package
  5. VSCode Salesforce Extension Pack
  6. Salesforce Code Builder

152. What is the minimum test coverage required to deploy to production?

Answer: The minimum test coverage required is 75% to deploy to production. If this is not satisfied then the apex class or trigger cannot be deployed to production.

153. What does the lightning component bundle contain?

Answer:  

The lightning component contains the following:

  1. Component
  2. Controller
  3. Helper
  4. Style
  5. Documentation
  6. Renderer
  7. SVG
  8. Design

154. Name the different lightning component models?

Answer: 

The two lightning component models are 

  1. Aura Component Model
  2. Lightning Web Component Model

155. What is Lightning App Builder?

Answer:

The lightning app builder is used to create lightning pages for the Salesforce Lightning experience and mobile apps. The Lightning App Builder is a point-and-click tool. Lightning Pages are built using Lightning components which are compact, configurable, and reusable elements that can be dragged and dropped into different regions of the page in the Lightning App Builder. It is very useful and easy to use.

We can use it to create:

  1. App Page
  2. Home Page
  3. Record Page

156. Which language does Lightning component use on Server side and Client side?

Answer: Lightning Component uses Javascript on the client side and Apex on the server side.

157. What are the tools used in Lightning?

Answer:

  1. Lightning App builder
  2. Lightning Connect
  3. Lightning Schema builder
  4. Lightning Process builder

158. What are the advantages of using Lightning?

Answer:

  1. Better Performance
  2. Out of the box component set
  3. Faster development
  4. Multiple device and cross-browser compatibility
  5. Event driven architecture
  6. Rich component ecosystem

159. Is there a limit to having lightning components in one application?

Answer: No, there is no limit to having lightning components in one application.

160. Where can we use Lightning Components?

Answer: We can use lightning components as:

  1. Drag and drop components in Lightning App builder and Community builder
  2. Quick Action buttons
  3. Lightning pages
  4. Lightning Record pages
  5. Stand alone Apps
  6. Overriding standard actions

161. How can we assign Lightning Pages?

Answer: Lightning pages can be assigned in three ways:

  1. The org default
  2. App default
  3. App ,record type ,profile

162What kind of framework does Lightning use?

Answer: Lightning uses Component based framework.

163. What are the different types of reports?

Answer:  Different types of reports are:

  1. Tabular Reports (Basic type of report)
  2. Summary Reports (Grouping by rows and sorting)
  3. Matrix Reports (Grouping by rows and columns )
  4. Joined Reports (can contain report from different report types)

164. What is a bucket field?

Answer:  A bucket field is a field which helps in categorizing records in a report. It can be used as any other field to sort, filter or group your report.

165. What is the difference between Standard and Custom reports?

Answer: Standard reports are created by Salesforce when we create objects and relationships. Custom reports fields can be specified by admin. We can also associate upto 4 objects.

166. What is a dashboard?

Answer: Dashboard can be simply put as a graphical representation of reports which can be tailored to a user and can also be set to a standard representation which is the same for all users. Dashboards can have upto 20 components. Dashboards show data according to the last run report.

167. What is a dynamic Dashboard?

Answer: Dynamic dashboards are used to display details according to the user’s security settings. It does not refresh on its own. It refreshes when the page is refreshed. Dynamic dashboards help to show data which is specific to that user and the data which he has access to.

168. How many records can we display on a single page in a report?

Answer: Salesforce allows us to display 2000 records on a page. If we need to show more records then the option is to export it into an excel file.

169. Can we create formula fields in Reports?

Answer: Yes formula fields can be used in all the other types of reports except Tabular. Formula should be in currency, percent or number type.

170. What kind of reports can be used to generate dashboards?

Answer: Summary and Matrix reports are used to generate dashboards.

171. Is it possible to delete reports using a data loader?

Answer: No ,it is not possible to delete reports using a data loader.

172. What is not supported in Joined reports?

Answer: 

  1. Bucket fields
  2. Cross filters
  3. The rows to display filters.

173. What is a Trigger? Name the different types?

Answer: Apex triggers allow us to perform custom actions before or after events to records in Salesforce, such as insertions, updates, or deletions. We use triggers to perform tasks which can’t be done by other point and click tools in Salesforce UI. There are two types of Triggers:

  1. Before Triggers (insert, update, delete)
  2. After Triggers (insert, update, delete, undelete)

174. What is a process builder? Why do we use it?

Answer: Process builder is a simple to use workflow tool to automate your business process. It provides a simple graphical representation which depicts the process. Process builder can be used to 

  1. Create a record
  2. Update the record
  3. Launch a flow
  4. Send an email
  5. Post to chatter
  6. Submit for approval
  7. Can do what all a workflow can do except for outbound messages

175. What is a workflow? What actions can be performed using it?

Answer: Workflow is an automation tool used to do simple tasks such as 

  1. Assigning a new task 
  2. Email Alerts
  3. Outbound messages
  4. Field Updates

176. What is an approval process? 

Answer: Approval process is used to provide the user a step by step guide to approve a certain process. We can configure to send an email, create a task etc when the approval process reaches a certain step of the process. The approval process consists of the following steps:

  1. Process definition
  2. Initial submission actions
  3. Step definitions
  4. Final Rejection actions
  5. Final Approval actions

177. What is a recursive trigger and how can we avoid it?

Answer: Recursive trigger is a situation where the actions of the trigger invoke the same trigger and it goes on in a loop.To avoid this scenario a simple step is to create a static variable and check the state of the variable before executing the trigger.

178. How is process builder and flow builder different?

Answer: Simply put the process builder is designed to be the simpler tool. It is much linear in process as compared to Flow builder. Flow builder is much more powerful not only in terms of the process design but also actions. Flow builder has a delete functionality along with being able to update multiple records. It is true that process builders are also able to update multiple records but it is limited in updating only child records of the parent record which started the process.

179. What are the conditions which need to be specified when we need to schedule actions?

Answer:  There are two conditions which need to be specified:

  1. Only when record is created
  2. When record is created or edited and defined criteria is met

180. What is a queue?

Answer: A queue is used to hold a predefined set of objects and users. Anyone in the queue can pick up a task assigned to the queue and can complete it. A queue can contain users, public groups, partner users, roles, roles and subordinates etc.

181. What are context variables and how do we use them?

Answer: Trigger Context variables (TCV) can be defined as those variables which help us in tracking the runtime information of the current execution of a trigger.Some of them are:

  1. isExecuting: This variable returns the value true if the current context for the Apex code happens to be a trigger and does not happen to be a Visualforce page, a Web service, or an execute anonymous() API call.
  2. isInsert: This variable returns the value true if the trigger executed is an insert operation
  3. isUpdate: This variable returns the value true if the trigger executed is an update operation
  4. isDelete: This variable returns the value true if the trigger executed is a delete operation
  5. isBefore: This variable returns the value true if the trigger was fired before any record was saved
  6. IsAfter: This variable returns the value true if the trigger was fired after all record was saved
  7. isUndelete: This variable returns the value true if the record was recovered from recycle bin
  8. new: This variable returns the list of the new versions of the sObject records. This is only available in insert, update and undelete triggers.
  9. newMap: This returns the list of Ids of the new version of the sObject records
  10. old: This variable returns a list of all the old versions of the sObject records. This is only available in update triggers and delete triggers
  11. oldMap: This variable returns the list of Ids of the old versions of the sObject records
  12. size: This is variable returns the total number of records invoked by the trigger 

182. What is the order of execution of Trigger, Process Builder and workflow?

Answer:  The order of execution is Trigger => Workflow => Process Builder

183. What is Integration? Explain.

Answer: Integration is connecting two applications. An enterprise uses a lot of applications which are not designed or created to work with each other.Integration helps the enterprise in getting the best efficiency , consistency and quality of all the applications working together. Each application can have different business logic, data and security layers which all need to be integrated.

184. What are the different ways to integrate in Salesforce?

Answer: There are 3 different ways to integrate in Salesforce:

  1. User interface integration: Combine the UIs of two or more apps to create composite apps with little or no rework on the UI of each individual app.
  2. Business Logic Integration: Apex Web Services is used for Inbound and Apex Callouts for Outbound. It typically handles a scenario where business logic is spread across several applications to implement the complete end-to-end business process.
  3. Data Integration: SOAP APIs and REST APIs are used here. It typically handles data synchronisation requirements, where one application in an enterprise acts as the primary source for a particular business object, like Account.

185. How many APIs are available in Salesforce?

Answer: They are 11 different APIs. They are:

  • REST API
  • SOAP API
  • Bulk API
  • Streaming API
  • Metadata API
  • Chatter REST API
  • User Interface API
  • Analytics REST API
  • Apex REST API
  • Apex SOAP API
  • Tooling API

186. What is webservices?

Answer: Webservices is a functionality which helps us to do integration. Web services are open standard (XML, SOAP, HTTP, etc.) based web applications that interact with other web applications for the purpose of exchanging data. Web services can convert your existing applications into web applications.

187. What is JSON?

Answer: JSON (Javascript Object Notation). JSON is lighter than XML . When transferring data between two communication channels it needs to be in Text, JSON is text and can be converted to Javascript and vice-versa with ease. JSON is then used to send messages between servers.

188. Why do we need test classes in Salesforce?

Answer: Test classes are used to write unit tests for Apex classes and triggers in salesforce. We need to write test classes which have more than 75% code coverage of the apex class and triggers. When we need to deploy apex classes or triggers in production we need to upload the test classes along with it . If the test classes fail to cover 75% of the code then deployment fails.

189Syntax of a simple test Method?

Answer: 

1
2
3
4
5
6
7
@isTest
private class MyTestClass { 
   static testMethod void myTest1() {
   }
   static testMethod void myTest2() {
   }
 }

190. What are assert statements and why are they used?

Answer:  Assert statements are used to compare what the real value is and what the expected value is. There are 3 types of assert statements:

  1. system.assertEquals(val1,val2)
  2. system.assertNotEquals(val1,val2)
  3. system.assertEquals(val1> val2)

191. What is seeAllData?

Answer: The test classes cannot recognise the data in the database by default and hence we need to mention the @isTest(seeAllData=true)  so that it recognised the data in the database.

192. What all needs to be tested in Apex?

Answer: Salesforce recommends we test :

  1. Single records
  2. Bulk records
  3. Positive scenarios
  4. Negative scenarios
  5. Restricted User

193. What is LWC? What does a Lightning Web component bundle contain?

Answer: LWC is a new programming model to help developers build Lightning components for Salesforce. It makes use of Javascript more and does not use Apex making it easier for developers with javascript knowledge to build components in salesforce without any apex knowledge. It is much faster and lighter as it uses Javascript. The lightning component bundle contains :

  1. HTML
  2. Javascript
  3. XML 

Files by default when we create a new LWC component. We need Salesforce CLI to work with LWC. 

194. Difference between imperative and wired apex methods

Answer:  

Wired apex methods- are called every-time the page refreshes or the reactive properties are changed .Data returned is immutable. We can only perform Read query operations using wired apex methods. We need to use @wired in front of the function name. If we want to refresh then we have to call refreshApex().

Imperative apex methods – need to be called explicitly.Data returned is mutable.We can perform DML operations on imperative operations.DML operations cannot be done if the apex method is annotated with cacheable=true .It is invoked as promises inside a function.

195. What is @api and @track ? When do we use each?

Answer: @api is used if we need to make the property or function to be public. @track was used to make it reactive but since Summer 19 release all properties are reactive by default. Now @track is used to re-render arrays or objects as it does not render by default if one element of the array is changed or the object’s property is changed.

196. Can we use Aura inside a LWC and vice-versa? 

Answer: No , we cannot use Aura inside a LWC but the opposite can be done i.e we can use LWC inside the Aura component. We can also use LWC inside flows, page components etc.

197. Name some data types used in aura components?

Answer: 

  • String
  • Integer
  • Boolean
  • Decimal
  • Double
  • Long
  • DateTime
  • Date
  • Array
  • List
  • Set
  • Map
  • sObject

198. How many events do we have in Aura components? How are they used?

Answer: There are three types of events:

  1. Component Events: Used when data is sent from child to parent.
  2. Application Events: Used when data is sent from one component to another component which are not in any hierarchy
  3. Standard Out of Box Events: Some default events which can be used by us. Example: showToast.

199. What is Visualforce?

Answer: Visualforce is a component based framework that is using tag based markup language like HTML. The framework is based on the MVC paradigm where controllers can be generated automatically and integrated with the database.

200. What is a visualforce controller. What are they used for?

Answer: Visualforce controllers helps us in handling what happens when a user performs a certain function such as clicking a button or link.There are 3 different types of controllers:

  1. Standard Controllers( save , edit, cancel and delete)
  2. Custom Controllers ( can override standard and create new functionality)
  3. Controller extensions (extend standard controllers)

201. What is a wrapper class?

Answer: A wrapper or container class is a class, data structure, or an abstract data type whose instances are a collection of other objects.It is a custom object defined by Salesforce developer where he defines the properties of the wrapper class. Within Apex & Visualforce this can be extremely helpful to achieve many business scenarios within the Salesforce CRM software.

202. What is Static Resources ? How is it helpful?

Answer: Static resources help us in uploading documents, files, images, libraries archived as .zip, and .jar files. These can be later referenced in Visualforce pages or lightning pages. These static resources are references using $Resource variables.

203. What are OOB functionality/Features provided by Sales Cloud Salesforce?

Answer: Contact Management, opportunity Management, Lead Management, Report and Dashboard, Mobile, Activity Management, Pipeline and forecasting Management, Process automation, File Sync and share, Salesforce Engage, Sales collab0ration, Territory Management, Sales Data and Intelligence, Partner Management

204. Optimized below code?

trigger accountTestTrggr on Account (before insert, before update) {
for(Account a: Trigger.new){

List<Contact> lstCon= [select id, salutation, firstname, lastname, email
from Contact where accountId in : a.Id];
for(Contact c: lstCon){
c.Description=c.salutation + ‘ ‘ + c.firstName + ‘ ‘ + c.lastname;

update c;
}

 

Ans: trigger accountTestTrggr on Account (before insert, before update) {
List<Contact> lstCont = new List<Contact>() ;
Set<Id> setActId = new Set<Id>();

for(Account a: Trigger.new){
setActId.add(a.Id);
}

for(Contact c: [select id, salutation, firstname, lastname, email
from Contact where accountId in : setActId]){
c.Description=c.salutation + ‘ ‘ + c.firstName + ‘ ‘ + c.lastname;

lstCont.add(c);
}

if(lstCont.size()>0) upsert lstCont;
}

205. What are OOB / features provided by Service Cloud salesforce?

Ans: Lightning Service Console: Increase agent productivity with the next-generation of agent experience. Put all the information agents need at their finger tips for a 360-degree view of customers.

Case Management: Resolve cases faster with easy visibility into the full context of all cases and a record of every customer interaction — all on a streamlined dashboard.

Workflow and Approvals: Customize and automate any customer service or approval process with drag-and-drop simplicity using Workflow.

Omni Channel-Routing: Deliver smarter service by automatically matching cases to the agent with the best skill set to solve them.

Telephone Integration: Integrate with the most popular CTI systems. Log notes instantly when customers call. Plus, manage calls from within the console without touching the phone.

Social Customer Service: Monitor and respond faster to customer posts on social media channels like Twitter, Facebook, Instagram, and others.

Automation with Macros: Free up your support agents by automating common, repetitive, multi-step tasks to resolve customer issues more efficiently. 

Account and Contact Management: Be ready when customers reach out to your company by arming agents with critical data about past communications right at their fingertips.

Custom Report and Dashboard: Make informed decisions with real-time reports. Track cases and customer information for a 360-degree view of the customer.

Asset and Order Management: Track customers’ assets, orders, support history, and more, in one place for a complete view of their activity.

This type of interview will be purely based on how your organization uses Salesforce. Some of the common questions asked are:

1. What license does your organization use?
2. What platform have you worked on?
3. How is the working model in your organization ?
4. What is the process of development and deployment?
5. How do you backup the data in your organization ?
6.What profile do you use to test? What all permissions are provided?
7. Which feature have you worked on most ? Questions based on that
8. What are your day to day duties?
9. Are you involved in solving production tickets? If yes how is the process of resolution
10. What is the toughest work in salesforce you have undertaken until now?