Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
40 views

SF Interview Question Sheet Last

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

SF Interview Question Sheet Last

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Salesforce Developer interview Questions

Salesforce fundamentals..............................................................................................................4
Objects - Fields............................................................................................................................5
Profile - Role................................................................................................................................6
What is a profile?.....................................................................................................................................................6
What is Role ?.......................................................................................................................................................... 6
Difference between Role and Profile?......................................................................................................................6
What is a dependent picklist?..................................................................................................................................7
What is Page Layout and Record Types?..................................................................................................................7
How to freeze users in salesforce.com?...................................................................................................................7
Which fields cannot be added as a custom Index?...................................................................................................7

Security.......................................................................................................................................7
What are different Levels of data access in Salesforce?...........................................................................................7
What is Organization-wide defaults?.......................................................................................................................8

What are Sharing Rules?.............................................................................................................8


What is Manual sharing?..........................................................................................................................................8
What is Profile..........................................................................................................................................................8
What is Permission Set?...........................................................................................................................................8
What is “View all” and “Modify all” permission?.....................................................................................................9
Is it possible to restrict permission for users using permission set?.........................................................................9
If a user does not have access to a specific record type, will they be able to see the records that have that record type?
................................................................................................................................................................................. 9
What is a Sharing Rule?............................................................................................................................................9
Difference between profiles and permission sets?...................................................................................................9
Tell me about Field-Level Security?..........................................................................................................................9
What are Login Hours and Login IP Ranges?............................................................................................................9
What are Organization Wide Defaults?....................................................................................................................9
What is a Role and Role Hierarchy?..........................................................................................................................9
What are the different types of Sharing Rules in Salesforce and explain them?....................................................10
In how many ways can we share a record?............................................................................................................10
How can i provide record level access to user’s in an organisation? then what should i use from Salesforce security model?
............................................................................................................................................................................... 10
How can you change the setting “Grant Access Using Hierarchies” for Standard Objects ?...................................10
What are the Mandatory points that you think while creating User and Role ?.....................................................10
While setting OWD (Organization wide sharing), can we change/modify the setting of child record in case of Master-Detail
relationship?.......................................................................................................................................................... 10
Number of accesses available in Organization Wide Defaults and what are they?................................................10

Relationships.............................................................................................................................10
What are the different types of Relationships in SFDC?What are they?.................................................................10
What is a “Look-up Relationship”?.........................................................................................................................11
What is “Master-Detail Relationship”?...................................................................................................................11
What is Roll-up summary?.....................................................................................................................................11
Define various characters of Roll-up Summary Field?............................................................................................11
List out the functions of Roll-up Summary field ?..................................................................................................11
What is Many-Many Relationship in Salesforce ?...................................................................................................11
Can we have Roll up Summary fields in case of Parent-Child Relationships?.........................................................11
Is it possible to edit Roll up summary field value in a record?................................................................................11
Is it possible to create Roll up summary field on parent object ?...........................................................................11
What is Junction Object?.......................................................................................................................................11
Can we convert the look up relationship to Master Detail relationship? If so How can we convert?.....................11
Can we create Master Detail relationship on existing records?..............................................................................12
What happens to detail record when master record is deleted?...........................................................................12
What happens to child record when a master record is deleted in Look-up Relationship?....................................12

Reports & Dashboards...............................................................................................................12


What are different kinds of reports?......................................................................................................................12
What are Standard Reports?..................................................................................................................................12
What are custom Reports?.....................................................................................................................................12
What are Dashboards?...........................................................................................................................................12
What are the different Dashboard Components?..................................................................................................12

Workflow...................................................................................................................................13
What is Workflow?.................................................................................................................................................13
Different Workflow Components available in salesforce?......................................................................................13
What are the different workflow actions available in Salesforce?..........................................................................13
What is a Workflow Field Update?.........................................................................................................................13
What is Time-Dependent Workflow?.....................................................................................................................13
Is it possible to delete the workflow when the workflow is having any pending time dependent actions?...........14
What is the use of re-evaluate workflow?..............................................................................................................14
What are the Time-Dependent Workflow Limitations?..........................................................................................15
Trigger vs Workflow?..............................................................................................................................................15

PROCESS BUILDER...............................................................................................................15
Explain Recursion – Allow process to evaluate a record multiple times in a single save operation?......................16
Do you want to execute the actions only when specified changes are made to the record?.................................16
What should be the condition we need to specify in process builder to specify schedule actions?.......................16
Is it possible to edit the process once it is activated?.............................................................................................16
What can be done using Process Builder?..............................................................................................................16
Update all related case and Contacts with the same email of account whenever account email changed............16
Process Builder Vs Apex Trigger?............................................................................................................................16
How to call Future methods from Process Builder?...............................................................................................17
What are the things which we can not do with process builder in Salesforce?......................................................17
What kind of related records can we update using process builder in Salesforce?................................................17
Flow...................................................................................................................................................17
What is difference between screen flow and auto launched flow?........................................................................17
What is invocable method?....................................................................................................................................17
Difference between flow and process builder?......................................................................................................17
Can we change the data type of variable once we have created in lightning flow designer?.................................17
What are the ways in which flows can be launched?.............................................................................................17
Can we query process Builder / Flow.....................................................................................................................18

Developer Questions..................................................................................................................18
Trigger...............................................................................................................................................18
What is a Trigger?.................................................................................................................................................. 18
What are the various event on which a trigger can fire?........................................................................................18
What are the considerations while implementing the Triggers?............................................................................18
What are context variables in triggers?..................................................................................................................18
What are the considerations while implementing the Trigger Context Variables...................................................19
How is Trigger.New Different from Trigger.newMap?.............................................................................................20
How is Trigger.new different from Trigger.old?.......................................................................................................20
Can a trigger call a batch class?..............................................................................................................................20
Can a trigger make a call to Apex callout method?................................................................................................20
What will you do if a method inside apex class need to be executed only when it is getting called from trigger?.20
What is the use of trigger.isexecuting?...................................................................................................................20
Is the id of record changes if we undelete a deleted record?.................................................................................20
What is a Recursive Trigger?..................................................................................................................................20
How to avoid Recursive Trigger?............................................................................................................................20
What do you mean by the bulkifying trigger?........................................................................................................20
What is difference between Triggers and Workflow rules?....................................................................................21
What are limitations of Workflows overcome by Triggers in Salesforce.................................................................21
Difference between Validation rules and Triggers?................................................................................................21
Why Process Builder and how is it differ from trigger?..........................................................................................21
What are the best practices for Triggers?...............................................................................................................22
Governor Limits......................................................................................................................................................22
Best practices to avoid Governor Limits.................................................................................................................22
What is the difference between database.insert and insert?.................................................................................23
Can you explain the order of execution in Triggers?...............................................................................................23
Batch Classes.....................................................................................................................................24
How many active batches(running parallel) can be allowed at a time?..................................................................24
Why to use Batch class as we already having data loader to process the bulk data...............................................24
How many times the execute method will be executed to process the 1234 records...........................................24
What is the maximum size of a batch that we can set up ?....................................................................................25
Can we call future method in batch class?.............................................................................................................26
What is the difference between database.batchable & database.batchablecontext bc?.......................................26
What if you change the name of Execute method to Execute1 in the batch class? Will the batch job still run?....26
Is there a way in which I can call a future method from a batch Job?....................................................................27
Future and Queueable APEX............................................................................................................27
Why Future?.......................................................................................................................................................... 27
When future is used?.............................................................................................................................................27
Why Queueable Apex?...........................................................................................................................................27
When queueable is used?......................................................................................................................................27
Differences between Future and Queueable Apex:................................................................................................27
Security in Apex (System/User Mode, With/Without Sharing, Access)..................................................................28
With Sharing vs. Without Sharing..........................................................................................................................28
Test Classes........................................................................................................................................28
Test Types...............................................................................................................................................................28
How is code coverage calculated?..........................................................................................................................28
Which classes are excluded from code coverage calculation?................................................................................29
How to retrieve code coverage information?.........................................................................................................29
Unit Test Best Practices..........................................................................................................................................29
Test classes best practices......................................................................................................................................29
Why to create separate class for testing purpose?.................................................................................................30
What are the considerations of using isTest annotation?.......................................................................................30
What are the things to remember when we use @testSetup method?.................................................................30
What is the difference between testMethod and @isTest?...................................................................................30
@testVisible annotation?.......................................................................................................................................30
How is a class defined as a test class ?...................................................................................................................30
Exception Handling................................................................................................................................................ 30

Aura..........................................................................................................................................31
Where to use Lightning Components?...................................................................................................................31
What are the components bundles used in the Lightning component?.................................................................31
Can Lightning be viewed as an MVC(model view controller) framework?.............................................................32
Which Lightning components parts are server-side and which ones are client-side?............................................32
Is it possible to include a Lightning component into another?...............................................................................32
What are Aura Components? Why we use Aura: Namespace in the code?...........................................................32
Are there any CSS (styles) provided by Salesforce.com for Supported Lightning Components?............................32
Is it possible to integrate lightning components with a framework such as Angular?............................................32
Are there any options for Lightning Record Page Assignment?..............................................................................32
How to create a custom Lightning Record Page?...................................................................................................32
What are the attributes? What are the parameters required?...............................................................................33
Which interface to use if you want your component to be available for all pages?...............................................33
Which interface can be used to get the id of the record from the record Detail page?..........................................33
What are the type of events into Salesforce Lightning component........................................................................33
What is the basic difference between Application Event and Component Event...................................................33
What are the propagation phases of Component Events?.....................................................................................33
What are the propagation phases of Application Events?......................................................................................33
What is the key difference between Application and Component Events?............................................................33
In which cases should you use Application Events and when are Component Events preferable?.........................33
Data Binding:..........................................................................................................................................................33

LWC...........................................................................................................................................34
LWC data binding................................................................................................................................................... 34
LWC Life Cycle of Events.........................................................................................................................................34
Decorators on LWC or Reactive Operators.............................................................................................................34
Lightning message service......................................................................................................................................35
Lightning Web Components Best practices............................................................................................................35
What are lifecycle hooks in LWC ?..........................................................................................................................36
Communication between child-parent:..................................................................................................................37
What do you mean by cacheable = true annotations ?.........................................................................................37
What is LMS (Lightning Message Service)?............................................................................................................37
LWC vs Aura........................................................................................................................................................... 37

Salesforce fundamentals
“Cloud Computing is a new trend in IT development, deployment, Delivery module of business Products, Services that are provided over the
internet that are been used by the real time User“
It’s a concept that where people or companies can carry out their daily processes or development, deployment processes or meet their server
needs with using some outer source.
Error: Reference source not found
Expand CRM and briefly explain about CRM ?
Full form for CRM or Acronym for CRM is “Customer Relationship Management “. We can understand from the full form where CRM is an
application used to automate Sales and marketing functions by a using a Software called CRM Software . BY using CRM Software every
Company / Organization plans to (make their inner processes about customer data they have more easy and more sustainable )increase their
revenues and profits. This strategy of increasing revenue is done mainly by attracting Customers, clients, Sales etc.
Error: Reference source not found
List some CRM Software’s?
We have number of CRM softwares which are provided by top CRM companies some of them are listed below depending upon their present
market.
 Salesforce CRM.
 Microsoft Dynamics CRM.
 Oracle CRM.
 SAP CRM.
 Sage CRM.
 NetSuite CRM.
 Oracle CRM on Demand.
 Oracle Sales Cloud(Fusion CRM).
 SugarCRM.
 Nimble
Error: Reference source not found
What are the Advantages of Cloud Computing?
 Cloud computing has made tremendous growth in processing power, reliability of the Internet and the great increase in broadband speeds.
 It makes tremendous sense to make use of the centralized server of the provider of cloud computing services as not only does it reduce the costs
by a great extent by making redundant the need to buy several software licenses, it also eliminates the huge costs required by an organization to
maintain and upgrade existing software.
What is the definition of CRM?
“Cloud Computing definition given by NIST (US National Institute of Standards and Technology) : Cloud Computing is a model for
enabling ubiquitous, convenient, on-demand network access to a shared pool of configurable computing resources that can be rapidly
provisioned and released with minimal management effort or service provider interaction“.
Error: Reference source not found
What are deployment modes of cloud computing?
Cloud computing services can be provided in four different deployment modes depending on size and structure of an organization. Four
deployment modes of cloud computing are
Public Cloud.
Private Cloud.
Hybrid Cloud and
Community Cloud.

Error: Reference source not found


What is PaaS?
PaaS means” Platform as a Service”. Here in “PaaS “ the cloud service providers provides hardware, OS(operating System), Storage,
Network services over the cloud. It is the way like a rent. If there is no service like Platform and there will be no Applications. Which
applications are build on a Platform.

What is SaaS?
SaaS means Software as a Service. Through this Services all the software’s are distributes over the cloud. By using SaaS no need to install any
software all software’s are readily available over the internet .
Error: Reference source not found
What is IaaS?
Full form IaaS is “Infrastructure as a Service”. Here in IaaS the cloud service providers will provides infrastructure like servers, hosting services
and storage. Servers and storage’s are the basic services provide by Cloud Service Providers.

What is Public Cloud?


Public cloud can be available to people across the world. In this Public Cloud the user has no control over the resources.
Error: Reference source not found
What is Private Cloud?
Private Cloud Can be accessed only with in the limited premises. In Private cloud Cloud Services Providers Cloud infrastructure to particular
Organization or Business specially. This Cloud infrastructure is not provided to others.
What is Hybrid Cloud?
Hybrid Cloud is the combination of number of clouds of any type but the cloud has the ability to allow data and / or applications to be moved
from on cloud to another cloud. Hybrid Cloud is a combination of (Public Cloud ,Private Cloud, Community Cloud). Here API is used as an
interface between public and Private Cloud.
What are the different types of Cloud Service providers?
Cloud Service Providers are those who provide cloud services to the business and customers or consumers. Cloud Service providers will have
huge data base, Data centers, infrastructure, software’s, platform and hardware systems.
Error: Reference source not found
Difference between Public and Private Cloud?
Public cloud can be available to people across the world. In this Public Cloud the user has no control over the resources. Where Private
Cloud Can be accessed only within the limited premises. In Private cloud Cloud Services Providers Cloud infrastructure to particular
Organization or Business specially. This Cloud infrastructure is not provided to others.
Salesforce.com is based on which cloud computing Service ?
Salesforce.com is based on Software as a Service ( SaaS).
Error: Reference source not founds
What are common factors on SaaS, PaaS, and IaaS?
SaaS, Paas and IaaS are the three types of services provided using “cloud”. Their common factor for providing services to organization and
customer is the “CLOUD”depending upon the types of the service they need. Saas provides Software service on cloud where PaaS provides
Platform for application development and finally IaaS provides Infrastructure.
What is Salesforce?
Salesforce is one of the best customer relationship management (CRM) tool. Salesforce is among one of the best web based flexible and
powerful database provider available in the market.
Get more details on Salesforce :- What is Salesforce.
Error: Reference source not found
Different Salesforce Editions?
Salesforce.com provides different types of editions and features depending upon the cloud. For Sales cloud it provides four different types of
editions. They ares
 Group.
 Professional.
 Enterprise.
 Unlimited.
Number of Salesforce Editions released per year?`
Salesforce Releases e updates for every year. They are
 Spring.
 Summer.
 Winter.
Difference between Salesforce.com and Force.com?
Salesforce.com and fore.com are relatively same but they are different in their functionality. Salesforce.com is used to develop CRM
functionality based application where force.com is used to customize our data model, business logic and User interface
Salesforce.com : SAAS
Force.com: PAAS
What is Database.com?
Database.com is a type of service provided by Salesforce.com to enhance the power of Salesforce.com CRM applications. Database.com
provides “Data as a Serivce” to subscribers.
How many types of portals are available in Salesforce?
In Salesforce.com we have three types of portals. They are
 Customer Portal.
 Partner portal.
 Self Service portal.
Error: Reference source not found
What is App in Sales force?
App means an Application. In Salesforce an Application consists a group of tabs which are designed to work as a single function. We have
number of applications in Salesforce.com some of them are sales, marketing, chatter, site.com, work.com etc.
We can create new application and also customization for the existing apps in Salesforce.com. To create new app in sfdc go
to Setup=>Build=>Create=>App.

Objects - Fields
Different types of object in Salesforce.com? And why they called so?
In Salesforce.com we have two types of objects. They are
 Standard objects.
 Custom Objects.
 Standard Objects :- Standard objects are called so because they are created and provided by Salesforce.com.
 Custom Objects :- Custom objects are those which are created by an User in salesforce.com.
Error: Reference source not found
What is an object in Salesforce?
An Objects is represented as a database table which stores organization data . Objects consists of set of fields and we store data against that
field. To view data Salesforce provided TABS.
To create custom fields go to Setup=>Build=>Create=>Object.
What is TAB in Salesforce?
Salesforce.com provides list of tabs and are placed in Tab menu. To access data of an objects Tabs are used. Tabs in Salesforce are three types
they are.
 Custom Tabs.
 *Visualforce Tabs.
 *Web Tabs.
List examples of custom field types?
Some of the custom field types are date field, Date/Time field, Currency field, Checkbox field, Number field, Text field, Pick list field, Email
field, percent fields, phone field, Url field and many more.
Error: Reference source not found
What are the Standard and Custom Fields in Salesforce?
 Standard fields for custom objects stores the information about created by, modified by, currency, Name, owner and Division. These are the
standard fields in Salesforce.com.
 Custom field for custom objects store unique data or information of an organization.
How many custom fields can I created in an object?
In Unlimited edition we can create up to 500 fields per object. In professional edition we can create up to 100 custom fields per object.
Error: Reference source not found

Profile - Role
What is a profile?
Profiles are those which defines user’s to perform different functions like settings and permissions in salesforce. It is another way to restrict or
control access to a particular record.
Profile are of two types.
 Standard Profile. Profiles created by force.com are called Standard Profiles.
 Custom Profile. Profiles created by user are called Custom Profiles.
Error: Reference source not found

What is Role ?
Role Hierarchy settings make the managers and subordinates to edit, and view the records. The users in the Hierarchy can be able to view,
edit and report all the data shared.
To create roles in salesforce go to setup=>Administer=>Manage Users=> Roles.

Difference between Role and Profile?


Roles :- Using we can provide record level access like organization wide defaults, Role hierarchy, sharing rules and Manual sharing. Simply
roles influences record level access.
Profiles :- Using profile object level and field level access can be made like general permissions, tab level permissions, read & write
permissions etc.
Error: Reference source not found
Number of standard profiles available in Salesforce.com?
In salesforce we have 6 standard profile they are.
 Standard user.
 Solution manager.
 Marketing User.
 Read only.
 System administrator.
How can you use the term “Transfer Record” in profile?
Transfer record is a type of permission in salesforce. If a user is is given access to transfer a record then the user will have the ability to transfer
the records which have Read access.
Error: Reference source not found
Tell me about Company Profile?
In salesforce.com company profile consists of information about language, locale, time zone, number of licenses, storage and available space,
about fiscal year, address and currencies.
How to get security token in Salesforce.com?
To get security token in salesforce.com go to your name=>Personal=>Reset my Security token.
What is a Fiscal Year in Salesforce?
Fiscal years in Salesforce are used to define starting and ending date of an organization financial year.Fiscal years in salesforce are two types
they are.
 Standard fiscal year :- To change starting month of the fiscal year this type is used.
 Custom fiscal year :- We can set custom fiscal year dates like quarters, weeks.
Error: Reference source not found
What is a dependent picklist?
Dependent Picklist allows to contain multiple values and pick value one among them or Multiple values among them. Dependent fields depends
upon controlling field.
Q: What type of fields can be in controlling and in dependent
What is Page Layout and Record Types?
 Page Layout :- In page layout customization can be done like fields, related lists, custom links can be arranged.
 Record Types :- Record types in salesforce helps to implement business processes like defining picklist values for standard and custom pick
lists.
How to delete user from Salesforce?
In salesforce.com, deleting a user is not possible. But the user can be deactivated by freezing that user in salesforce. To deactivate user go
to Setup=>Administer=>Manage users=>Users=>Click on Freeze.
Error: Reference source not found
How to freeze users in salesforce.com?
In salesforce.com, deleting a user is not possible. But the user can be deactivated by freezing that user in salesforce. To deactivate user go
to Setup=>Administer=>Manage users=>Users=>Click on Freeze.
What are Static Resources?
Static resources helps to store upload images, files, zip files, documents, javascript files, Css Files which can be used in visualforce pages ,
ligthning components. Maximum data storage limit for static resource is 250mb.
Error: Reference source not found
List some standard indexed fields in salesforce.com?
Id, name, owner fields, lookup fields, master-detail relationship fields, audit dates like Last Modified dates etc are the standard indexed fields in
Salesforce.com.
Which fields are Indexed by default in Salesforce?
Salesforce indexed some fields by default they are Id, name, owner fields, lookup fields, master-detail relationship fields, audit dates like Last
Modified dates.
Error: Reference source not found
Which fields cannot be added as a custom Index?
Formula fields.
In salesforce, Can two users’ can have same profile?
Yes.
Is it possible to edit formula field values in a record?
No.
Error: Reference source not found

Security
What are different Levels of data access in Salesforce?
Organization level security
For your whole org, you can maintain a list of authorized users, set password policies, and limit logins to certain hours and locations.
Object level security
Access to object-level data is the simplest thing to control. By setting permissions on a particular type of object, you can prevent a group of users
from creating, viewing, editing, or deleting any records of that object. For example, you can use object permissions to ensure that interviewers
can view positions and job applications but not edit or delete them.
Field level security
You can restrict access to certain fields, even if a user has access to the object. For example, you can make the salary field in a position object
invisible to interviewers but visible to hiring managers and recruiters.
Record level security
You can allow particular users to view an object, but then restrict the individual object records they’re allowed to see. For example, an
interviewer can see and edit her own reviews, but not the reviews of other interviewers. You can manage record-level access in these four ways.
 Organization-wide defaults
 Role hierarchies
 Sharing rules
 Manual sharing
Error: Reference source not found
Error: Reference source not found

What is Organization-wide defaults?


Organization Wide Defaults(OWD) in salesforce is the baseline level of access that the most restricted user should have. Organizational Wide
Defaults are used to restrict access. You grant access through other means like(sharing rules, Role Hierarchy, Sales Teams and Account teams,
manual sharing, Apex Sharing ). In simple words Organization Wide Defaults(OWD) specify the default level of access users have to each
other’s records.
For more details please level to below post Organization Wide Defaults(OWD) in salesforce
Error: Reference source not found

What are Sharing Rules?


Sharing Rules are automatic exceptions to organization-wide defaults for particular groups of users, so they can get to records they don’t own or
can’t normally see. Sharing rules, like role hierarchies, are only used to give additional users access to records. They can’t be stricter than your
organization-wide default settings.
What is Manual sharing?
It allows owners of particular records to share them with other users. Although manual sharing isn’t automated like org-wide sharing settings,
role hierarchies, or sharing rules, it can be useful in some situations, such as when a recruiter going on vacation needs to temporarily assign
ownership of a job application to someone else.
Error: Reference source not found
What is Profile
Each user has a single profile that controls which data and features that user has access to. A profile is a collection of settings and permissions.
Profile settings determine which data the user can see, and permissions determine what the user can do with that data.
 The settings in a user’s profile determine whether she can see a particular app, tab, field, or record type.
 The permissions in a user’s profile determine whether she can create or edit records of a given type, run reports, and customize the app.
Profiles usually match up with a user’s job function (for example, system administrator, recruiter, or hiring manager), but you can have profiles
for anything that makes sense for your Salesforce org. A profile can be assigned to many users, but a user can have only one profile at a time.
Error: Reference source not found
What are standard profiles?
 Read Only
 Standard User
 Marketing User
 Contract Manager
 System Administrator

What is Permission Set?


A permission set is a collection of settings and permissions that give users access to various tools and functions. The settings and permissions in
permission sets are also found in profiles, but permission sets extend users’ functional access without changing their profiles.
Permission sets make it easy to grant access to the various apps and custom objects in your org, and to take away access when it’s no longer
needed.
Users can have only one profile, but they can have multiple permission sets.
Note :- Manual sharing is available for only Organization wide default settings are private to the object.

Error: Reference source not found


What is “View all” and “Modify all” permission?
View all and Modify all permissions are usually given to system administrator. When you grant “View All” or “Modify All” for an object on a
profile or permission set, you grant any associated users access to all records of that object regardless of the sharing and security settings.
In essence, the “View All” and “Modify All” permissions ignore the sharing model, role hierarchy, and sharing rules that the “Create,” “Read,”
“Edit,” and “Delete” permissions respect. Furthermore, “Modify All” also gives a user the ability to mass transfer, mass update, and mass delete
records of that specific object, and approve such records even if the user is not a designated approver.
These tasks are typically reserved for administrators, but because “View All” and “Modify All” let us selectively override the system,
responsibilities that are usually reserved for the administrator can be delegated to other users in a highly controlled fashion.
Error: Reference source not found
Is it possible to restrict permission for users using permission set?
No, Permission Set always extends the permission. It does not restrict permission to users.
If a user does not have access to a specific record type, will they be able to see the records that have
that record type?
Yes, Record type controls only visibility of record on UI but not its access to users. If user does not have access to record type then user will not
be able to create records for that record type using UI. But user will we able to see records if they have appropriate permission to do so.
Error: Reference source not found
What is a Sharing Rule?
Sharing rules in Salesforce represent the permissions and exceptions to your organization. By using sharing rules we can grant access to edit,
read, read/write permissions to user. Sharing Rules are of two types. They are
1. Manual Sharing.
2. Automatic Sharing.
Error: Reference source not found
Difference between profiles and permission sets?
Permission Sets : In this Permission sets we define the access level of the user. Generally we determine what a user can do in the applications.
These are used to grant additional permission to a user.
Profiles : In Object level Security, Profiles are assigned to the user by system administrator. A profile can be assigned to many users where as a
user can have only one Profile.
How can you define Field Dependency?
In Field dependency, we have to fields controlling filed and dependent field. When a selection is made the controlling field controls dependent
picklist values.
Ex:- When a country is selected in dependent picklist then the states are available to that country. Here country is controlling field and State is
dependent field.
Error: Reference source not found
Tell me about Field-Level Security?
In field level security, we control the user what to see, edit, delete of a particular field in the object.
Briefly describe about Field-Level Security?
In field level security, we control the user what to see, edit, delete of a particular field in the object. In some situation like if we want to grant
access control over Object to a user but the user should not be able to access some particular fields in that objects then we go for Field Level
Security.
Field Level Security can be controlled by Profiles and Permission sets.
Error: Reference source not found
What are Login Hours and Login IP Ranges?
 Login hours are set in an organization to restrict the user’s who tries to login before or after login hours.
To set login hours in an organization go to Setup=>Administration=>Manage users=>Profiles.
 IP ranges are used to restrict any login attempt is done from unknown IP addresses. Usually organizations maintain login IP ranges.
To set Login IP ranges in salesforce go to Setup=>Administration Setup=>Manage Users=> Profiles.
What is a User Record?
User records consist key information about the user.
Error: Reference source not found
What is a Record Owner?
Record Ownership : The User or Queue who controls and have the right to access a record.
Generally there are two types of Owners. They are
 Users.
 Queues.
Error: Reference source not found
What are Organization Wide Defaults?
 Organization wide Defaults define the baseline level of access to data records for all users in an Organization.
 Organization wide Defaults are used to restrict access to data(Records).
 Organization wide Defaults(OWD) can be defined for Standard Objects and Custom Objects.
What is a Role and Role Hierarchy?
Salesforce uses role hierarchy to automatically to grant access to users by default. We can not edit Grant Access using Hierarchies for standard
objects and can edit Grant Access using Hierarchies check box for Standard objects.
Error: Reference source not found
What is Access at the Role Level?
Access at the role level depends upon the organization wide defaults.
What are the different types of Sharing Rules in Salesforce and explain them?
 Account sharing Rule.
 Contact Sharing Rule.
 Case Sharing Rule.
 Opportunity sharing Rule.
 Lead Sharing Rule.
 Custom Object sharing Rule.
Error: Reference source not found
In how many ways can we share a record?
Records can be shared in 5 types they are
1. Role Hierarchy.
2. Organization Wide Defaults.
3. Manual Sharing.
4. Criteria Based Sharing Rules.
5. Apex Sharing.
Error: Reference source not found
How can i provide record level access to user’s in an organisation? then what should i use from
Salesforce security model?
record level sharing.
If i want Object level accesses then what should i use from Salesforce security model?
Object level sharing.
Error: Reference source not foundError: Reference source not found
Is it possible to bypass Grant Login access using Hierarchies in case of standard objects?
Yes
Can we use sharing rules to restrict data access?
No, sharing rules cannot restrict data access.
Is it possible to create sharing rules for detail object?
No, we can create sharing rules for details objects because they don’t have owner field.
Error: Reference source not found
OWD Questions
How can you change the setting “Grant Access Using Hierarchies” for Standard Objects ?
It is not possible , by default Grant Access Using Hierarchies options are enabled for standard objects and they can not be changed.For custom
objects we can change “Grant Access Using Hierarchies “settings .
What are the Mandatory points that you think while creating User and Role ?
It’s Profile.
While setting OWD (Organization wide sharing), can we change/modify the setting of child record in
case of Master-Detail relationship?
No, we can not change the settings of child record in Master Detail relationship because child record is controlled by parent record.
Error: Reference source not found
Number of accesses available in Organization Wide Defaults and what are they?
We have 13 types of access in Organization default settings. They are
1. Private
2. Controlled by parent
3. Public Read Only.
4. Public Read/Write.
5. Public Read/Write/Transfer.
6. Public Full Access.
7. Use.
8. No Access.
9. View Only.
10. Hide Details.
11. Hide Details and Events.
12. Show Details.
13. Show Details and events.
Error: Reference source not found
Relationships
What are the different types of Relationships in SFDC?What are they?
They are four types of Relationships in Salesforce.com. They are
1. Master-Detail relationship.
2. Look-up Relationship.
3. May-Many Relationship.
4. Hierarchy Relationship (we can not use this relationship).
What is a “Look-up Relationship”?
 No parent is required.
 Relationship is optional.
 No impact on Security.
 Roll-Up summary fields cannot be available.
 40 look-up relationships can be created to one Object.Salesforce can increase it to 50 on request.
Error: Reference source not found
What is “Master-Detail Relationship”?
 Child record must have a associated parent.
 Cascade record-level security.
 Cascade record deletion.
 Roll-up Summary fields can be established.
 Standard objects can not be a detail object.
 Standard Objects can be a Master object
 Maximum 2 Master-Detail Relationships can be created to a Object.
 Records can be re parented.
 Can create junction object using master detail
Error: Reference source not found
What is a “Self Relationship”?
Self Relationship is nothing but creating relationship between two same objects. This Self Relationship is a Look-up Relationship to the same
object.
Error: Reference source not found
What is Roll-up summary?
Roll-Up Summary field in salesforce calculates values from a set of related records.
Define various characters of Roll-up Summary Field?
1. Roll-Up Summary field can be created only in a object which is referred as a object with a master detailed relationship field.
2. Roll-Up Summary field can only created for Master-detail Relationship.
3. Roll-Up Summary field can not be created for Look-up Relationship.
4. It Derives the data from child Object.
5. We can’t change field type of a field that we reference in a roll-up summary field.
6. Auto numbers are not available here.
7. Roll-Up Summary fields are not available for mapping lead fields of converted fields.
Error: Reference source not found
List out the functions of Roll-up Summary field ?
 Count : It calculates the total number of related records.
 Sum : It totals the values of selected fields.
 Min : Displays lowest value.
 Max : Displays the highest value.
What is Many-Many Relationship in Salesforce ?
 Many-Many Relationships between two objects can be created.
 Junction Object is used to create Many-Many Relationship.
 Junction object can also be called as Join Object.
 Junction Object links each objects in Many-Many Relationship.
Error: Reference source not found
Can we have Roll up Summary fields in case of Parent-Child Relationships?
No.
Is it possible to edit Roll up summary field value in a record?
No. roll up summary fields are read only fields and they can not be edited.
Is it possible to create Roll up summary field on parent object ?
Yes, we can create Roll up Summary field on parent object only with master detail relation between objects.
How to create Many – to – Many relationship?
Create junction Object.
Error: Reference source not found
What is Junction Object?
In salesforce, Junction Object are the part of the objects which joins one object to another. These are specially used to join many objects
in Many to Many relationships.
What are the main things need to consider in the “Master-Detail Relationship”?
Cascade deletion of the child records is done when parent record is deleted in Master-Detail Relationship.
Can we convert the look up relationship to Master Detail relationship? If so How can we convert?
Yes, we can convert Look-Up relationship to Master-Details Relationship. Conversion can be done only if all the fields have valid look-Up fields
values only.
Error: Reference source not found
Can we create Master Detail relationship on existing records?
Yes, It is possible to create Master-Detail Relationship on existing record. First we have to create Look-Up relationship to a record then convert
it to master-Detail Relationship.
Error: Reference source not found
In case of Master-Detail relationship, on Update of master record can we update the field of child record using workflow rule?
No
In case of Master-Detail relationship, on Update of child record can we update the field of Parent record using workflow rule?
Yes, we can update the field of Parent record using workflow rule.
Error: Reference source not found
What happens to detail record when master record is deleted?
When master Record is deleted, it’s detail records are also deleted.
What happens to child record when a master record is deleted in Look-up Relationship?
Child records are not deleted.
A custom object contains some records, now my requirement is to create field in this object with master detail relationship.
No. we can no create master detail relationship first create look up relationship and associate look fields for every parent record and then convert
this to Master detail relationship.
Error: Reference source not found
Can we create both master detail relationship and Look-Up Relationship at a time ?
Yes, we can create.

Reports & Dashboards.


What are different kinds of reports?
There are three types of reports in salesforce.com they are
 Tabular reports.
 Summary reports.
 Matrix reports
Error: Reference source not found
What are Standard Reports?
Standard reports in salesforce are those provided by salesforce.com. These type of reports can not be deleted and used primarily for creating
custom reports.
What are custom Reports?
Custom reports in salesforce are those created by user with specific criteria. These type of report can be deleted, edited and stores in personal
folders.
What is a Tabular report ?
Tabular reports in salesforce are those where the data is displayed in the form of list. In Tabular reports custom data is arranged with out
subtotals.
Error: Reference source not found
What is a Summary Report?
Summary reports in salesforce are those where the data is displayed in the form of summary format. Sorting, sum-total of data can be available
in this report.
What is a Matrix Report?
Matrix reports is salesforce are those where the data is arranged in grid format having rows and columns. Data is arranged vertically and
horizontally in tables like excel format.
What is Trend Report?
Trend reports in salesforce are those which displays historical data. Trend reports are used to analyse which fields contains data that we want to
leave out.
Error: Reference source not found
What are Custom Report Types?
Custom report types in salesforce allows us to build framework in the report wizard when creating custom reports. This custom reports can be
created between standard and custom objects.
Who can run Reports?
In Salesforce.com, most reports run automatically when we click on the report name. If we want to run a report click on “Run Report” to run
automatically.
Error: Reference source not found
What is a bucket field in reports?
In salesforce reports, bucket fields are used to categorize reports records . When we use bucket field in reports there is no need of creating
formula or a custom field.
Is it possible to delete reports using Data loader?
No, it is not possible to delete reports using data loaders.
Error: Reference source not found
What are Dashboards?
Salesforce Dashboards are the graphical representation and visual presentation of reports data in salesforce.
What are the different Dashboard Components?
Salesforce dashboard components are used to represent data. Salesforce dashboards have some visual representation components like graphs,
charts, gauges, tables, metrics and visualforce pages. We can use up to 20 components in single dashboard.
What are dynamic Dashboards?
Dynamic dashboards in Salesforce displays set of metrics that we want across all levels of your organization. Enterprise Editions can use five
dynamic dashboards and Unlimited edition can use ten dashboards.
Error: Reference source not found
Can we schedule dynamic dashboards?
No, we can not schedule dynamic dashboards for refresh. It must be done manually.
Explain dynamic Dashboard.
Dynamic dashboards in Salesforce displays set of metrics that we want across all levels of your organization.
Dynamic Dashboards in salesforce are Created to provide security settings for the dashboards in salesforce.com. We may have a requirement in
an organization to “view all data” by every user in an organization according to their access we have to select Run as Logged-in User. There are
two setting option in Dashboards. They are
 Run as specified User.
 Run as Logged-in User.
Error: Reference source not found
Who can access “drag and drop dashboard”?
User who have permissions in managed dashboard can access drag and drop dashboard.
Which type of report can be used for dashboard components?
Summary reports and Matrix reports are used for dashboard components.
Error: Reference source not found
Which permission is required to set the running user other than you in dashboard?
The user must have “View All Data” permission is required to set the running users.
What is the use of “floating report header”?
Floating report headers enables us to display the column header visible on each page when we scroll the report page.
How to enable “floating report header”?
To enable floating report header in salesforce go to Setup=>Customize=>Reports and Dashboards=>User Interface settings=>Click on enable
floating report header.
What is Analytical Snapshot in Salesforce.com ?
Analytical Snapshot in Salesforce are used to create reports on historical data.
Error: Reference source not found

Workflow
What is Workflow?
Salesforce Workflow is a business logic that evaluates the records as they are created, updated in an object to apply automated process
like Assigning Tasks, Emails, Field Update and outbound message sending.
Different Workflow Components available in salesforce?
In salesforce.com. workflows consists of 5 components they are.
1. Workflow rules.
2. Workflow tasks.
3. Workflow Email alerts.
4. Workflow field updates.
5. Workflow Outbound messages
What are the different workflow actions available in Salesforce?
1. Tasks.
2. Email alerts.
3. field updates.
4. Outbound messages
Error: Reference source not found
What is a Workflow Task?
Workflow tasks in salesforce are used to assigns a task to users. Using tasks we can specify the Subject, Status, Priority, and Due Date of the
task. Tasks are workflow & approval actions that are triggered by workflow rules or approval processes.
What is a Workflow Alert?
Email alert is one of the action used in workflow and approval. They are used to generate email template by a workflow rule or approval process
and sent to destination recipients. We can send workflow email alerts to users, contacts having a valid email address.
Error: Reference source not found
What is a Workflow Field Update?
Field updates in workflow and approval processes specifies the field that we want updated and inserting the new value for it. Depending on the
field type, we can choose the following options. They are apply a specific value, make the value blank, or calculate a value based on a formula
you create.
What is Time-Dependent Workflow?
Time dependent workflows are not executed independently. Time dependent workflows remain constant in the workflow queue as long as the
workflow rule criteria is valid.
Time-Dependent Workflow – Considerations?
When defining time dependent workflows in salesforce we have to use standard and custom date and date/time fields defined for the object.
 We have to specify time using days and hours.
 Also add actions to existing time triggers.
Error: Reference source not found
Limitations of Time-dependent workflow?
When defining time dependent workflows in salesforce we have to use standard and custom date and date/time fields defined for the object.
 We have to specify time using days and hours.
 Also add actions to existing time triggers.
In which criteria of a workflow – “time dependent workflow action” cannot be created ?
Created, and every time it’s edited.
When you can’t add Time dependent action in Workflow rule?
Time dependent actions in workflow rules can not be added when the following actions takes place.
 When workflow rule is active.
 When workflow rule is deactivated and has pending actions in the queue.
 When the workflow rule criteria of a record is set to: created, and every time it’s edited.
 When the workflow rule is included in a package.
Error: Reference source not found
We have a “Time Based Workflow” and there is Action scheduled to be executed. If we Deactivate the workflow, Scheduled actions will
be removed from queue or not?
Even after deactivating the workflow, its action will not be removed. It’s still active in queue.
We have “Time Based Workflow” and there is action scheduled to be executed. Can we delete that workflow?
It is not possible to delete the workflow when the workflow is having any pending time dependent actions.
How to clear the Time based workflow action queue?
We can clear time based workflow action queue in two ways they are
1. Make the criteria false.
2. Removing scheduled actions from the queue.
Error: Reference source not found
While creating workflow on Task, what difference observed on available actions?
While creating workflow on task we can not find “Send Email”action.
Suppose if a record meets workflow criteria for time based workflow action, the action goes in queue. Later, before the time based action is
triggered, the same record gets modified and the criteria previously met is changed and now it does not meet the workflow criteria. What
happens to the time based action placed in Queue?
Simply the time based workflow action is removed from workflow queue and will not get fired.
Error: Reference source not found
Whenever case is created send email to case owner. How to do that?
We can do it using workflow.
I have two workflow Rules and two fields F1 and F2.
When ever F1 is updated to value= 10, WF1 fires and updates F1 value to 20 and F2 value to 30
When ever F1 values= 20 there is another Workflow WF2 fires which will update F1 to 10 and F2 to 20
What will be the outcome of this Workflow rule.
• This scenario will cause recursive Workflow rule
• This will exhaust the governor limit and result in error
Is it possible to delete the workflow when the workflow is having any pending time dependent actions?
No
Error: Reference source not found
What is the use of re-evaluate workflow?
 If the field update changes the field’s value, all workflow rules on the associated object are re-evaluated. Any workflow rules whose criteria are
met as a result of the field update will be triggered.
 If any of the triggered workflow rules result in another field update that’s also enabled for workflow rule re-evaluation, a domino effect occurs,
and more workflow rules can be re-evaluated as a result of the newly-triggered field update. This cascade of workflow rule re-evaluation and
triggering can happen up to five times after the initial field update that started it.
 Make sure that your workflow rules aren’t set up to create recursive loops. For example, if a field update for Rule1 triggers Rule2, and a field
update for Rule2 triggers Rule1, the recursive triggers may cause your organization to exceed its limit for workflow time triggers per hour.
Example if field A=10 => Change it to field B = 100
If field B=100 => Change field A=10
 Only workflow rules on the same object as the initial field update will be re-evaluated and triggered.
 Only workflow rules that didn’t fire before will be retriggered.
 Cross-object workflow rules aren’t candidates for re-evaluation.
 Cross-object field updates that cause a field value to change don’t trigger workflow rule re-evaluation on the associated object.
 An approval process can specify a field update action that reevaluates workflow rules for the updated object. If, however, the re-evaluated
workflow rules include a cross-object field update, those cross-object field updates are ignored.
 Time-dependent actions aren’t executed for a reevaluated workflow rule in the following situations:
 The reevaluated workflow rule’s immediate actions cause the record to no longer meet the workflow rule criteria.
 An Apex after trigger that is executed as a result of a workflow or approvals action causes the record to no longer meet the workflow rule
criteria.
Error: Reference source not found
How to avoid recursive workflow?
 For the workflow Evaluation Criteria if you choose created, and any time it’s edited to subsequently meet criteria option, we can avoid recursive
workflow rules.
 If you don’t enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update of a workflow rule we can avoid.
 For example, suppose that for an opportunity record to meet the rule criteria, the opportunity probability must be greater than 50%. If you create
an opportunity with a probability of 75%, the workflow rule runs. If you edit that opportunity by changing the probability to 25%, the edit
doesn’t cause the rule to run. If you then edit that opportunity by changing the probability from 25% to 75%, the edit causes the rule to run. With
this last edit, the rule runs, because the record is changed from not meeting the rule criteria to meeting the rule criteria.
Error: Reference source not found
What is Cross-Object Field Updates?
For all custom objects and some standard objects, you can create actions where a change to a detail record updates a field on the related master
record.
For example, in a custom recruiting application, create a workflow rule that sets the status of an application (the master object) to “Closed” when
a candidate (the detail object) accepts the job. Or, for standard objects, create a rule to change the status of a case from “Awaiting Customer
Response“ to “In Progress” when a customer adds a case comment.
Error: Reference source not found
What happens if workflow rule has time trigger set to past?
If a workflow rule has a time trigger set for a time in the past, Salesforce queues the associated time-dependent actions to start executing within
one hour. For example, if a workflow rule on opportunities is configured to update a field 7 days before the close date, and you create an
opportunity record with the close date set to today, Salesforce starts to process the field update within an hour after you create the opportunity.
What happens if we change the rule criteria of time based workflow and updated rule don’t match the criteria?
Time-dependent actions remain in the workflow queue only as long as the workflow rule criteria are still valid. If a record no longer matches the
rule criteria, Salesforce removes the time-dependent actions queued for that record.
Error: Reference source not found
What are Limitations of Time Based workflow?
 Time triggers don’t support minutes or seconds.
 Time triggers can’t reference the following:
 DATE or DATETIME fields containing automatically derived functions, such as TODAY or NOW.
 Formula fields that include related-object merge fields.
 Salesforce limits the number of time triggers an organization can execute per hour. If an organization exceeds the limits for its Edition,
Salesforce defers the execution of the additional time triggers to the next hour.
 If time-based workflow actions exist in the queue, you can’t add or remove time triggers or edit trigger dates without deleting the actions first.
Because the deleted records can’t be restored, carefully consider the implications of editing the workflow rules before you proceed.
 You also can’t add or remove time triggers if:
 The workflow rule is active.
 The workflow rule is deactivated, but has pending actions in the queue.
 The workflow rule evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited.
 The workflow rule is included in a package.
Error: Reference source not found
What are the Time-Dependent Workflow Limitations?
Time triggers don’t support minutes or seconds.
Time triggers can’t reference the following:
• DATE or DATETIME fields containing automatically derived functions, such as TODAY or NOW.
• Formula fields that include related-object merge fields.
When cannot you add or remove time trigger from workflow?
You can’t add or remove time triggers if:
• The workflow rule is active.
• The workflow rule is deactivated but has pending actions in the queue.
• The workflow rule evaluation criteria are set to Evaluate the rule when a record is: created, and every time it’s edited.
• The workflow rule is included in a package
Error: Reference source not found
We have Time Based Workflow and there is action scheduled to be executed. Can we delete that workflow?
If a workflow has any pending time dependent action, then we cannot delete the workflow.
How to clear the Time based workflow action queue?
1. Make criteria false for all those records.
2. Navigate to Set up -> Monitoring -> Time Based Workflow, search for scheduled actions and remove from queue.
When the Add Time Trigger button is unavailable?
The evaluation criteria are set to Evaluate the rule when a record is: created, and every time it’s edited.
The rule is activated.
The rule is deactivated but has pending actions in the workflow queue.
Error: Reference source not found
Trigger vs Workflow?
Salesforce Workflow:
 It is an automated process that can shoot an action which is based on evaluation and rule criteria.
 Performing DML operations in the workflow is not possible.
 You can obtain a workflow over an object.
 You can’t create a query from the database.
Salesforce Trigger:
 It is a piece of code which is executed either before or after a record is updated or inserted.
 More than 15 DML operations can be used in a single trigger.
 More than 20 SOQLs can be used from the database in a trigger.
 You can access triggers across an object and related to that object.
Limitations of Workflows That Triggers in Salesforce Overcome
 Workflows cannot create or update a separate object.
 You can’t reference certain fields when using workflows.
 You will not have your workflow doing more than just field updates and emails.
Error: Reference source not found

PROCESS BUILDER
Points to consider when calling apex class from process builder?
 Only Classes that have @InvocableMethod annotation will be listed for selection. Use this annotation at the method level.
 The method should be static and public or global.
 A class can only have one method which has this annotation.
 Can’t use other annotations with @InvocableMethod annotation.
 Invocable methods can have only one parameter. These methods can accept only a list of primitive data types or list-of-lists of the primitive data
types
Error: Reference source not found
Explain Recursion – Allow process to evaluate a record multiple times in a single save operation?
When you add objects to your process, you can choose to evaluate a record multiple times in a single save operation.
If you choose this option, the process can evaluate the same record up to five additional times in a single save operation. It might reevaluate the
record because a process, workflow rule, or flow updated the record in the same save operation. When a record is reevaluated, the process uses
the most recent values for that record.
For example, your sales review process includes multiple steps, approvals, notifications, and fields that need to be updated. Some of these
changes may be part of your process, or they may be managed by other workflow rules or flows in your org. If you let the process reevaluate a
record multiple times in a single save operation, you can manage and evaluate all of these changes—even changes from other processes—in a
single save operation in your process.
Example:
In process builder = if b=100 =>change c= 200
In flow if a-10 => b =100
Initial Value :b, c =>0 a=10
B has no value so process builder is bypass
Flow has a=10 so b becomes 100

Now Process builder already ran but we have checkbox true-so it verifies.
Now as b = 100, so c becomes 200
Error: Reference source not found
Do you want to execute the actions only when specified changes are made to the record?
It is equal to Created or edited to subsequently match the criteria of workflow
What should be the condition we need to specify in process builder to specify schedule actions?
Below are 2 conditions:
Only when record is created
When record is created or edited and while define criteria select the checkbox for below setting
Is it possible to edit the process once it is activated?
No, You need to clone and while cloning you can create new process or create new version.
Error: Reference source not found
What can be done using Process Builder?
Creating records: This will allow you to create a new record and create different field values for a record.
Updating records: You can update one or more records which are somehow related to the record that started the process. This can be done either
by manually entering records or by using the records from a related record.
Posting on Chatter: Process Builder allows you to post on Chatter for sharing any information to any user.
Quick action: If you already have global actions or objects, within Salesforce, you can use Quick action to use them in any other record.
Launch/trigger the flow: It is possible for you to launch the flow from your process to automate different processes.
Submitting the record automatically for approval: The record which started your process can be submitted. Any other record can’t be
automatically submitted.
Call/trigger Apex code: You can invoke an Apex code which you have already written within Salesforce.
Invoking another process: This action will actually invoke a process to another process.
Whenever there is any change into Contact Email update custom field of Associated Account with the latest Changes into the account
email.
We will go for process builder because using workflow we cannot update related record other than master detail
Update custom field of Account Object?
Workflow is the right automation tool for the above scenario
Update all related case and Contacts with the same email of account whenever account email changed.
Process Builder will be the right tool to use here as we need to update all contacts and cases there may be more than 1 and Process Builder
allows you to do the same.
Count no of child records related to master record into Lookup relation.
You have to go for the custom solution using Apex Trigger.
Error: Reference source not found
What DML operations can be done using Process builder
1. Process Builders cannot handle before DML It executes after a record has been created or updated. Whereas Apex triggers can handle both
before and after DML operations.
2. Process Builder cannot handle delete and undelete DML. Whereas Apex triggers can handle all DML operations.
Process Builder Vs Apex Trigger?
Process Builder Apex triggers

You cannot handle before DML operation.It executes only after a record You can handle both before and after DML operations.
has been updated or created.

You cannot handle deleting and undelete DML. You can handle all DML operations.

An error reported in Process Builder is more generic which makes it Exception handling can be made more specific.
difficult to find the origin of the error.

You cannot update unrelated records. You can update unrelated records.

You have to use Process Builder in conjunction with flows to create Share records with more complex criteria than sharing Rules
custom record sharing. Permits.

You cannot create email templates that pull information from multiple You can create email templates that pull information from
records and objects combined, solely by using Process Builder. multiple records and objects (combined with Visualforce).
Error: Reference source not found
What is Mixed DML Operation and how to solve Mixed DML Operation Error in Process Builder in Salesforce?
If any user wants to perform DML operation on setup and non-setup object in the same transaction then there is a chance of generating “Mixed
DML Operation” error.
Example:
ABC company give a requirement to their employees, if any employee joins our company then we will create a user in user object and as well as
we will auto create a sick leave, casual leave, earn leave in there leave balance object which is a custom object. If an employee will perform this
scenario then an employee will get Mixed DML Operation error.
Solution:
As we know we can not use DML operation on the setup and non-setup object in the same transaction then we have to separate it by time
dependent trigger
Error: Reference source not found
How to call Future methods from Process Builder?
To call Future methods from Process Builder, call the future method from the invocable method.
What are the things which we can not do with process builder in Salesforce?
1. Deleting Records (Alternative: Flows/Apex Trigger )
2. Outbound Message (Alternative: Workflow/Apex Trigger)
3. Cloning a record (Alternative: Apex Trigger)
4. Updating unrelated records (Alternative: Flows/Apex Trigger)
Error: Reference source not found
What kind of related records can we update using process builder in Salesforce?
 Parent Records (Master or Lookup)
 Child Records (Master or Lookup)

Flow
Error: Reference source not found
What is difference between screen flow and auto launched flow?
Screen Flow-Requires user interaction, because it includes screens, local actions, steps, choices, or dynamic choices. Screen flows don’t support
Pause elements.
Autolaunched Flow-Doesn’t require user interaction. This flow type doesn’t support screens, local actions, choices, or choice sets
What is invocable method?
@InvocableMethod annotation is required for callinsg any apex method from flow.
For Flow, care should be taken to retrieve records once and then loop through them rather than repeatedly retrieving records through multiple
loops (this is equivalent to not performing SOQL within a loop).
Error: Reference source not found
Difference between flow and process builder?
Process Builder Salesforce Flow

Can’t be used to delete records. Can be used to delete records.

Not all objects are supported by Process Builder. Many objects are accessible using Salesforce Flow. For example –
OpportunityContactRole, UserDevice, etc.

Can be triggered when a record is created or edited. Can be triggered when a record is created, edited, or even deleted.

Can’t be triggered after a successful login. Can be triggered when a user successfully logs into Salesforce.

Not possible to save the newly created record ID (If it is created Possible to store the newly created record ID in a variable; so that, you
using the Record Create element). can reference it in a flow later.

Good for the intermediate use case. Much more power to implement complex logic.
Can’t be used to capture user input(s). Can be used to capture the user input(s) and later process it based on
your business use case.

Can be Schedule to run daily, weekly or once.


Error: Reference source not found
Can we change the data type of variable once we have created in lightning flow designer?
No we cannot change the data type once created
What are the ways in which flows can be launched?
A Screen Flow can be launched using one of the following
1. Using Flow Component in Lightning Record Page
2. Using Flow Component in Lightning App Page
3. Using Flow Component in Lightning Home Page
4. Using Flow Component in Lightning for Outlook
5. Using a Custom Button
6. Using a Custom Link
7. Embed a Flow in Visualforce Page
8. Using Login Flow
9. Using Inline Visualforce Page
10. 10.Using Quick Action
Error: Reference source not found
Can we query process Builder / Flow
No we cannot query but we can see details through workbench ->Info–> MetaDataTypes & Components>Flow>Components.

Developer Questions
Trigger
Error: Reference source not found
What is a Trigger?
The trigger is defined as an Apex code that execute before or after the following functions such as insert, update and delete etc. Trigger enables
to perform custom actions before and after modifications to the records of Salesforce.
Types of Apex triggers
There are two types of triggers:
• Before trigger are used to update or validate values of a record before they are saved to the database.
• After trigger are used to access field values of the records that are stored in the database and use these values to make changes in other records.
The records that fire the after trigger are read only.
Trigger Syntax
1 trigger TriggerName on ObjectName (trigger_events) {
2
3 // Implement the Logic here
4 code_block
5}
Example:
1 trigger myAccountTrigger on Account (before insert, before update) {
2
3 CreateAccount.getAccount();
4
5}
1. myAccountTrigger – triggerName ( It is the name you would want to give your trigger).
2. Account – Objectname (It is the object on which the action needs to be performed).
3. before insert, before update – Trigger_events
Before insert: When using this event, the code block gets executed before a new record is inserted.
Before update: When you use this event, the code will get executed before a new record is updated in the object.

What are the various event on which a trigger can fire?


A trigger is a set of statement which can be executed on the following events. In above trigger events one or more of below events can be used
with comma separated.
• before insert
• before update
• before delete
• after insert
• after update
• after delete
• after undelete
Error: Reference source not found
What are the considerations while implementing the Triggers?
Consider the following before implementing the triggers.
Upsert trigger fires on 4 different events :- before(insert, update), after (insert, update)
• Field history is updated after the trigger has successfully finished processing data.
** Any callout should be asynchronous so that trigger does not have to wait for the response.
•** A trigger cannot have a static keyword in its code.
• If a trigger completes successfully the changes are committed to the database and if it fails the transaction is rolled back.
Error: Reference source not found
What are context variables in triggers?
When ever a trigger is invoked it has a group of supportive variables. Which hold runtime information during the current trigger execution and
these variables are known as Trigger Context Variables (TCV).

Error: Reference source not found


Following are the context variable available in triggers. Please note variable availability in trigger varies according to the type of trigger events.

Variable Usages

Returns true if the current context for the Apex code is a trigger, not a Visualforce page, a Web service, or an
isExecuting
executeanonymous() API call.

isInsert Returns true if this trigger was fired due to an insert operation.

isUpdate Returns true if this trigger was fired due to an update operation.

isDelete Returns true if this trigger was fired due to a delete operation.

isBefore Returns true if this trigger was fired before any record was saved.

isAfter Returns true if this trigger was fired after all records were saved.

isUndelete If a record is recovered from the recycle bin it returns trigger true.

Returns a list of the new versions of the sObject records. This sObject list is only available in insert, update, and
new
undelete triggers, and the records can only be modified before triggers.

A map of IDs to the new versions of the sObject records. This map is only available in before update, after insert, after
newMap
update, and after undelete triggers.

Returns a list of the old versions of the sObject records. This sObject list is only available in update and deletes
old
triggers.
oldMap A map of IDs to the old versions of the sObject records. This map is only available in update and deletes triggers.

size The total number of records in a trigger invocation.

Error: Reference source not found


What are the considerations while implementing the Trigger Context Variables
• trigger.new and trigger.old cannot be used in Apex DML operations.
• You can use an object to change its own field values using trigger.new, but only in before triggers. In all after triggers, trigger.new is not saved,
so a runtime exception is thrown.
• trigger.old is always read-only.
• You cannot delete trigger.new.
How is Trigger.New Different from Trigger.newMap?
Trigger.New variable returns the list of sObject which has invoked the trigger and Trigger.NewMap returns the map of ID’s with the newly
entered records (key & value pair). NewMap is only available in after insert, before and after the update and after undelete.
Error: Reference source not found
How is Trigger.new different from Trigger.old?
Trigger.New variable returns the list of sObject which has invoked the trigger and Trigger.old returns a list of the older versions of the records
which have invoked the trigger.
Trigger.Old is only available in update and delete events.
Can a trigger call a batch class?
Yes, we can call a batch class in the trigger as we do in the normal apex code.
Can a trigger make a call to Apex callout method?
we can call a callout method in Apex Trigger but the only condition is that it has to be an asynchronous callout because the trigger flow cannot
wait on the response received by the callout method.
What will you do if a method inside apex class need to be executed only when it is getting called from
trigger?
We will use trigger.isexecuting in apex class to check if the method inside apex class is getting called from trigger and will execute the method if
getting called from trigger.
What is the use of trigger.isexecuting?
Suppose we have a method in apex class and we want this method to run only when the method is getting called from apex trigger than we can
make use of trigger.isexecuting in apex class to check if the method is getting called from trigger.
Is the id of record changes if we undelete a deleted record?
No, It has the same id.
Error: Reference source not found
What is a Recursive Trigger?
A recursive trigger is one that performs an action, such as an update or insert, which invokes itself owing to, say something like an update it
performs.
Error: Reference source not found
How to avoid Recursive Trigger?
Recursion occurs when some code is executed again and again. It can lead to infinite loop and which can result to governor limit some time.
Some time it can also result is unexpected output.
To avoid recursive triggers you can create a class with a static Boolean variable with default value true. In the trigger, before executing your code
keep a check that the variable is true or not. Once you check make the variable false.
Example 1:
Apex Class: checkRecursive.apxc
 public Class checkRecursive{
1 private static boolean run = true;
 public static boolean runOnce(){
2 if(run){
 run=false;
3 return true;
 }else{
4 return run;
 }
5 }
 }
6

7

8

9

10

11
Trigger Code: updateTrigger.apxt
 trigger updateTrigger on anyObject(after update) {
1 if(checkRecursive.runOnce())
 {
//write your code here
2
}
 }
3

4

5

6
Error: Reference source not found
What do you mean by the bulkifying trigger?
By default, all triggers in Salesforce are bulky triggers. This means you can process many records simultaneously. Bulky triggers can handle
bulk operations and single-record updates, such as the following :
• Data import
• Mass Fraction
• Bulk API calls
• The recursive apex methods
Note that
A trigger should be able to handle single record and thousands of record. There are two important point for it:
• Write triggers that operate on collections of sObjects.
• Write triggers that perform efficient SOQL and DML operations.
• If we will not follow above point we may hit governor limit when records are created/updated/deleted in mass using data loader or other tool.
16. Is there any limit on number of triggers define on an object?
We can define as many triggers on an object as we want but it is recommended to have one trigger per object because the order of execution of
different trigger is not guaranteed and any trigger can fire first.
Error: Reference source not found
What is difference between Triggers and Workflow rules?

Triggers Workflow

• Trigger is a piece of code that executes before or after a • Workflow is automated process that fired an action based on
record is inserted or updated. Evaluation criteria and rule criteria.

• Coding is required. • Coding is not required.

• We can access the trigger across the object and related to that
• We can access a workflow across the object.
objects.

• More than 15 DML operations can be used in a single • We cannot perform DML operation on workflow. Only insert and
trigger. update.

• We can use 20 SOQL’s from data base in one trigger. • We cannot query from database.

Error: Reference source not found


What are limitations of Workflows overcome by Triggers in Salesforce
• Workflows are not able to create or update a separate object.
• You can’t reference certain fields when using workflows.
• You will not have your workflow doing more than just field updates and emails.

Difference between Validation rules and Triggers?


Validation Rules Triggers

Validation rules are used to confirm that the data entered into Triggers can be used for various different things and can be executed
a record meet various data quality / business rules before at different times - e.g. when initiating a new record, before saving it,
letting the user save it. when a record is deleted.

Validation rules are very easy to create and virtually anyone Triggers are more complex and generally require some development
can learn how to create these. skills.

Error: Reference source not found


Why Process Builder and how is it differ from trigger?
Process builder is fully customization. No code required here because we require lengthy logic and record to complete and fulfil the requirement
or if we using process builder it will take less time to complete the requirement.
It has some benefits over the trigger:
Error: Reference source not found
SCENARIOS OPTION REASON

Scenario I
Populate a lookup field on record update:
Traditionally required a trigger and It can be Process Traditionally been something that requires a Trigger. Process
done easily with process builder. builder builder allows administrator can do this without the use of the
The issue is Multi layer lookup logic- i.e. Trigger code.
multiple / nested maps of related data required
in the trigger.

Process
Scenario II Process builder can be used to assign ownership of records based
builder
Set an Account Owner based on Record criteria on criteria in the object.
Trigger

Process
Scenario III Process builder can be used to post to chatter based on record
builder
Post a chatter message based on record criteria criteria.
Trigger

Scenario IV Process Requires 2 Processes one to Update the Quote based on the
Submit a Quote for Approval when builder opportunity stage and another to submit the quote for the approval
Opportunity Stage= Proposal Trigger when the criteria on the quote had been met.

Scenario V Process
Process builder can be used to set record criteria and then launch
Launch a Flow via record criteria vs a button or builder
a trigger ready flow.
link. Trigger

Scenario VI Process Although Process builder can create a new record it can’t
Clone an opportunity and change the field builder reference any of the values from the cloned opportunity without
values Trigger the use of a flow to capture the opportunity values.

Error: Reference source not found


What are the best practices for Triggers?
1. Write One-Trigger Per Object
A single Apex Trigger is all you need for one particular object. If you develop multiple Triggers for a single object, you have no way of
controlling the order of execution if those Triggers can run in the same contexts.
2. Logic-less Triggers
If you write methods in your Triggers, those can’t be exposed for test purposes. You also can’t expose logic to be re-used anywhere else in your
org.
3. Context-Specific Handler Methods
Using specific methods in your trigger-handler-class to keep your code clean and scalable.
4. Bulkify your Code
Bulkifying Apex code refers to the concept of making sure the code properly handles more than one record at a time.
5. Avoid SOQL Queries or DML statements inside FOR Loops
An individual Apex request gets a maximum of 100 SOQL queries before exceeding that governor limit. So if this trigger is invoked by a batch
of more than 100 Account records, the governor limit will throw a runtime exception.
6. Using Collections, Streamlining Queries, and Efficient For Loops
It is important to use Apex Collections to efficiently query data and store the data in memory. A combination of using collections and
streamlining SOQL queries can substantially help writing efficient Apex code and avoid governor limits.
7. Querying Large Data Sets
The total number of records that can be returned by SOQL queries in a request is 50,000. If returning a large set of queries causes you to exceed
your heap limit, then a SOQL query for loop must be used instead. It can process multiple batches of records through the use of internal calls to
query and queryMore
8. Use @future Appropriately
It is critical to write your Apex code to efficiently handle bulk or many records at a time. This is also true for asynchronous Apex methods (those
annotated with the @future keyword). The differences between synchronous and asynchronous Apex can be found.
9. Avoid Hardcoding IDs
When deploying Apex code between sandbox and production environments, or installing Force.com AppExchange packages, it is essential to
avoid hardcoding IDs in the Apex code. By doing so, if the record IDs change between environments, the logic can dynamically identify the
proper data to operate against and not fail.
10. Use a Framework
A framework! Why? It will make your code conform to the best practices, better testing, scalability and cleaner.

Governor Limits
• SF runs in a multitenant shared environment, where thousands of orgs share the same Salesforce Instance. Resources like CPU power, RAM and
bandwidth are all shared in the same Instance. As a result, and to protect the Instance resources, Salesforce has implemented Resource Usage
Limits. These are called Governor Limits.
Description Synchronous Limit Asynchronous
Limit
Total number of SOQL queries issued 100 200
Total number of records retrieved by 50,000
SOQL queries
Total number of records retrieved 10,000
by Database.getQueryLocator
Total number of SOSL queries issued 20
Total number of records retrieved by a 2,000
single SOSL query
Total number of DML statements issued 150
• Force.com Platform Apex Limits. Some limits aren’t specific to an Apex transaction and are enforced by the Force.com platform like; Max #
of Apex classes scheduled concurrently (100). Max # of batch Apex jobs queued or active concurrently (5). Max # of batch Apex job start
method concurrent executions (1). Max # of batch jobs that can be submitted in a running test (5)

Best practices to avoid Governor Limits


 One Trigger Per Object: A single Apex Trigger is all you need for one particular object. If you develop multiple Triggers for a single object,
you have no way of controlling the order of execution if those Triggers can run in the same contexts
 Logic-less Triggers: If you write methods in your Triggers, those can’t be exposed for test purposes. You also can’t expose logic to be re-used
anywhere else in your org.
 Context-Specific Handler Methods: Create context-specific handler methods in Trigger handlers
 Bulkify your Code: Bulkifying Apex code refers to the concept of making sure the code properly handles more than one record at a time.
 Avoid SOQL Queries or DML statements inside FOR Loops: An individual Apex request gets a maximum of 100 SOQL queries before ex-
ceeding that governor limit. So if this trigger is invoked by a batch of more than 100 Account records, the governor limit will throw a runtime
exception
 Using Collections, Streamlining Queries, and Efficient For Loops: It is important to use Apex Collections to efficiently query data and store
the data in memory. A combination of using collections and streamlining SOQL queries can substantially help writing efficient Apex code and
avoid governor limits
 Querying Large Data Sets - The total number of records that can be returned by SOQL queries in a request is 50,000. If returning a large set of
queries causes you to exceed your heap limit, then a SOQL query for loop must be used instead. It can process multiple batches of records
through the use of internal calls to query and queryMore
 Use @future Appropriately: It is critical to write your Apex code to efficiently handle bulk or many records at a time. This is also true for
asynchronous Apex methods (those annotated with the @future keyword). The differences between synchronous and asynchronous Apex can be
found
 Avoid Hardcoding IDs: When deploying Apex code between sandbox and production environments, or installing Force.com AppExchange
packages, it is essential to avoid hardcoding IDs in the Apex code. By doing so, if the record IDs change between environments, the logic can
dynamically identify the proper data to operate against and not fail
Or say this
● Do not have DML statements or SOQL queries in our FOR loop
● Try not to use SOQL or DML operations in the loop
● Try to bulkify the code and helper methods
● Query large data sets
● Use Batch Apex if we want to process 50,000 records
● Streamline various triggers on the same object
● Use streamlining queries and collections for loops

Error: Reference source not found


What is the difference between database.insert and insert?
insert is the DML statement which is same as databse.insert. However, database.insert gives more flexibility like rollback, default assignment
rules etc. We can achieve the database.insert behaviour in insert by using the method setOptions(Database.DMLOptions).
Important Difference:
insert
• Partial insert is not supported.
• Roll back is not supported.
• If we use the DML statement (insert), then in bulk operation if error occurs, the execution will stop and Apex code throws an error which can
be handled in try catch block.
Database.insert
• Database methods are static methods available in Database class.
• Partial insert is supported.
• Roll back is supported.
• If DML database methods (Database.insert) used, then if error occurs the remaining records will be inserted / updated means partial DML
operation will be done.
Example: If you are inserting 10 records.
5 having all the required fields value and remaining 5 records missing required fields value.
In DML statement (insert) all the 10 records will be failed, because if one record is incorrect or error means all other remaining records will not
be inserted. It will throw error.
In Database.insert 5 records will be inserted, remaining 5 records will be failed.(i.e. Partial DML Operation).
Error: Reference source not found
Can you explain the order of execution in Triggers?
Following is the order of execution of events which Salesforce perform before a DML Event.
1. Loads the original record from the database or initializes the record for an upsert statement.
2. Loads the new record field values from the request and overwrites the old values.
If the request came from a standard UI edit page, Salesforce runs system validation to check the record for:
3.
3.1. Compliance with layout-specific rules
3.2. Required values at the layout level and field-definition level
3.3. Valid field formats
3.4. Maximum field length
When the request comes from other sources, such as an Apex application or a SOAP API call, Salesforce validates only the foreign keys. Before
executing a trigger, Salesforce verifies that any custom foreign keys do not refer to the object itself.
Salesforce runs custom validation rules if multiline items were created, such as quote line items and opportunity line items.
4. Executes record-triggered flows that are configured to run before the record is saved.
5. Executes all before triggers.
6. Runs most system validation steps again, such as verifying that all required fields have a non-null value, and runs any custom validation rules.
The only system validation that Salesforce doesn't run a second time (when the request comes from a standard UI edit page) is the enforcement
of layout-specific rules.
7. Executes duplicate rules. If the duplicate rule identifies the record as a duplicate and uses the block action, the record is not saved and no further
steps, such as after triggers and workflow rules, are taken.
8. Saves the record to the database, but doesn't commit yet.
9. Executes all after triggers.
10. Executes assignment rules.
11. Executes auto-response rules.
12. Executes workflow rules. If there are workflow field updates:
 Updates the record again.
 Runs system validations again. Custom validation rules, flows, duplicate rules, processes, and escalation rules are not run again.
 Executes before update triggers and after update triggers, regardless of the record operation (insert or update), one more time (and only one more
time)
13. Executes escalation rules.
14. Executes the following Salesforce Flow automations, but not in a guaranteed order.
14.1. Processes
14.2. Flows launched by processes
14.3. Flows launched by workflow rules (flow trigger workflow actions pilot)
When a process or flow executes a DML operation, the affected record goes through the save procedure.
15. Executes entitlement rules.
16. Executes record-triggered flows that are configured to run after the record is saved.
17. If the record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field
in the parent record. Parent record goes through save procedure.
18. If the parent record is updated, and a grandparent record contains a roll-up summary field or is part of a cross-object workflow, performs
calculations and updates the roll-up summary field in the grandparent record. Grandparent record goes through save procedure.
19. Executes Criteria Based Sharing evaluation.
20. Commits all DML operations to the database.
21. After the changes are committed to the database, executes post-commit logic such as sending email and executing enqueued asynchronous Apex
jobs, including queueable jobs and future methods.
Error: Reference source not found
Batch Classes
What is apex Flex Queue?

The Apex Flex queue enables you to submit up to 100 batch jobs for execution. Any jobs that are submitted for execution are in holding status
and are placed in the Apex Flex queue. Up to 100 batch jobs can be in the holding status.
Error: Reference source not found
Can you change order of job in Apex Flex Queue?
Jobs are processed first-in first-out—in the order in which they’re submitted. You can look at the current queue order and shuffle the queue, so
that you could move an important job to the front, or less important ones to the back.

1
2Boolean isSuccess = System.FlexQueue.moveBeforeJob(jobToMoveId, jobInQueueId);
3

How many active batches(running parallel) can be allowed at a time?


Salesforce by default allows 5 active batches running at a time and other batches will be in queue for running
Error: Reference source not found

Why to use Batch class as we already having data loader to process the bulk data.

Agree with this point if and only if the data needs to be updated is static or predefined or which can be done through excel.

We will choose batch class if we have to perform some custom calculations at run time or if you want to run some complex logic which can't be
driven by excel sheets in those cases we have to go with batch classes.

Examples:
 Do some relationship quires to update the data.
 Make a call out to get the some information related to each record.
Error: Reference source not found
How many times the execute method will be executed to process the 1234 records.
It depends on your batch size what you have configured at the time of calling the batch class from schedule class.

Execution method count = Total No Of Records/Batch Size (Any decimal ceil it to upper value)
If you haven't set any batch size then - 1234/200 = 6.17 = 7 times execute method will be called

Error: Reference source not found


What is the maximum size of a batch that we can set up ?
2000

What is the minimum batch size we can set up is?


1
Error: Reference source not found
What is the default size of batch if we haven't configured at the time of execution?
200
Explain status of jobs in Apex Flex Queue?

Holding : Job has been submitted and is held in the Apex flex queue until system resources become available to queue the job for processing.
Queued : Job is awaiting execution.
Preparing : The start method of the job has been invoked. This status can last a few minutes depending on the size of the batch of records.
Processing : Job is being processed.
Aborted : Job aborted by a user.
Completed : Job completed with or without failures.
Failed : Job experienced a system failure.
Error: Reference source not found
Can you write a batch class blueprint?

1
2 global class batchExample implements Database.Batchable<sObject> {
3 global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext bc) {
4
5 // collect the batches of records or objects to be passed to execute
6 }
7
8 global void execute(Database.BatchableContext bc, List<sObject> records){
9 // process each batch of records
10 }
11
12 global void finish(Database.BatchableContext bc){
13 // execute any post-processing operations
14 }
15
16 }
17
Error: Reference source not found

Let’s say Record A has to be processed before Record B, but Record B came in the first Batch and Record A came in the second batch.
The batch picks records which are unprocessed every time it runs. How will you control the processing Order?
The Processing order can’t be controlled, but we can bypass the record B processing before Record A. We can implement Database.STATEFUL
and use one class variable to track whether Record A has processed or not. If not processed and Record B has come, don’t process Record B.
After all the execution completes, Record A has already been processed so Run the batch again, to process Record B.
Let’s say, we have run an apex batch to process 1000 records, and It is running with batch size 200. Now, while doing DML on 395th
record, an error occurred, What will happen in that case?
In batches, If the first transaction succeeds but the second fails, the database updates made in the first transaction are not rolled back.
Since the batch size is 200, so the first batch will be processed completely and all data will be committed to DB. In seconds batch, if we are
committing records using normal DML statements like insert, update than the whole batch will be rollbacked. So records 201 to 400 will not be
processed.

How can you stop a Batch job?


The Database.executeBatch and System.scheduleBatch method returns an ID that can be used in System.abortJob method.
Error: Reference source not found
Write batch apex program to get phone no. in the Contact object with the phone no. in the Corresponding Account object. Where
Contact is a child of Account.

1
2 global class ContactUpdate implements Database.Batchable<sObject>
3 {
4 global Database.QueryLocator start(Database.BatchableContaxt bc)
5 {
6 String query = 'select id, phone, Account.phone from Contact';
7
8 return Database.getQueryLoactor(query);
9 }
10 global void execute(Database.BatchableContext bc, List<Contact> scope)
11 {
12 for(contact con: scope)
13 {
14 con.phone = con.Account.phone;
15 Conlist.add(con);
16 }
17 update con;
18 }
19 global void finish(Database.Batchable Context bc)
20 {
21
22 }
23 }
24

Create an Apex Class to invoke the batch apex job.


Error: Reference source not found
1
2 public class TestMyBatch
3 {
4 public string cname{get; set;}
5 public pageReference show()
6 {
7 customerBatch mybatch = new customerBatch (cname);
8 Id id = Database.executeBatch (mybatch, 400);
9 system.debug ('My Job id' + id);
1 }
0 }
1
1
1
2
Can we call future method in batch class?
Methods declared as the future aren’t allowed in the classes that implement Database.Batchable interface.
Methods declared as future can’t be called from Batch Apex class.
Error: Reference source not found
What is the difference between database.batchable & database.batchablecontext bc?
1. database.batchable is an interface.
2. database.batchableContext is a context variable which store the runtime information eg jobId
What if you change the name of Execute method to Execute1 in the batch class? Will the batch job
still run?
Go ahead and change Execute to Excute1 and try saving the class.
Output
Class batchUpdateAccountsContacts must implement the method: void Database.Batchable<SObject>.execute(Database.BatchableContext,
List<SObject>)
Finding
It won let you save the batch class as it says class must implement execute method
Error: Reference source not found
Is there a way in which I can call a future method from a batch Job?
Calling a future method is not allowed in the Execute method, But a web service can be called. A web service can also call an @future
method. So, we can define a web service having a future method invocation and call the web service from the execute method of Batch Job.
Give example of Batch Apex class for deleting records?
Error: Reference source not found
1
2 public class BatchDelete implements Database.Batchable<sObject> {
3 public String query;
4 public Database.QueryLocator start(Database.BatchableContext BC){
5 return Database.getQueryLocator(query);
6 }
7 public void execute(Database.BatchableContext BC, List<sObject> scope){
8 delete scope;
9 DataBase.emptyRecycleBin(scope);
1 }
0 public void finish(Database.BatchableContext BC){
1 }
1 }
1
2
1
3
1
4
1
5

Future and Queueable APEX

Why Future?
If you want to run processes in a separate thread, at a later time and want to execute the code asynchronously, we need to use future methods.
Error: Reference source not found
When future is used?
These are used for long-running operations such as callouts to external Web services or any operation you would like to run in its own thread
Syntax:
global class <ClassName> {
//Below is future annotation which defines the given method is future method.
@future
public static void <FutureMethodName>(List<Id> recordIds) {
List<Contact> accounts = [Select Id, FirstName, LastName from Contact Where Id IN :recordIds];
// process contacts records to do awesome stuff
}
}
Error: Reference source not found
Why Queueable Apex?
Like the future is also used to execute the asynchronous code, and it enables you to add jobs in a queue and enhance the way of running
asynchronous code in comparison to the future method.
When queueable is used?
For Apex processes that run for a long time, such as extensive database operations or external Web service callouts, you can run them
asynchronously by implementing the Queueable interface
Syntax:
public class <Name of Queueable Class> implements Queueable {
//This is the only method which is contained by the Queueable Interface and required to inherit this method in Queueable class.
public void execute (QueueableContext context) {
//Code which needs to be executed
}
}
Error: Reference source not found

Differences between Future and Queueable Apex:


Future Method Queueable Job

1. Future will never use to work on SObjects 1. Queueable Jobs can contain the member variable as
or object types. SObjects or custom Apex Types.
2. When using the future method we cannot 2. When using queueable jobs it will make the AsyncApexJob
monitor the jobs which are in process. which we can monitor like Scheduled jobs.
3. The future method cannot be called inside 3. Queueable Apex can be called from the future and batch
the future or batch class. class.
4. The future method will never be queued. 4. Using Queueable Apex will chain up to queueable jobs and
in Developer Edition it is only 5 Jobs.

Security in Apex (System/User Mode, With/Without Sharing, Access)

System Mode vs. User Mode


• In SF, the Org. data in the database is accessed in one of 2 modes:
• System Mode: Allows the code to access all records in the database, even if the user executing the code doesn’t have access to. Ignores the shar-
ing model. System record access (Triggers, Custom Web Services, Test Classes). In conclusion, all Apex code run in system mode, ignoring
user's permissions.
• User Mode: Limits code access to only records that the user executing the code has access to, just like when the user access records using the
UI. Respects the sharing model. User record access (Anonymous Block). In conclusion, Only exception that run in User Mode: Execute Anony-
mous Block and Standard controllers.

With Sharing vs. Without Sharing


We use of with sharing or without sharing keywords on a class to specify whether sharing rules must be enforced.
 The with sharing keyword allows to specify that the sharing rules for the current user are considered for the class and we have to explicitly set
this keyword for the class because Apex code runs in system context.

 Use of without sharing keywords when declaring a class to ensure that the sharing rules for the current user are not enforced.

If we don't use the With/without Sharing keyword then the class will run in the System Context. In system context, Apex code has access to all
objects and fields— object permissions, field-level security, sharing rules aren't applied for the current user.

WITH SECURITY_ENFORCED (permission to Query)


WITH SECURITY_ENFORCED clause enables object-level or field-level security permissions checking for SOQL queries in Apex code,
including subqueries and cross-object relationships.

Classes inherit this setting from a parent class when one class extends or implements another. Inner classes do not inherit the sharing setting
from their container class.

Test Classes

Test Types
Error: Reference source not found
1. Single Records:
This includes testing to verify that a single record produces the correct,
expected result
2. Bulk Records:
Any apex code, whether a triggers, a class or on extension may be used
for 1to 200 records we must test not only the single record case, but the bulk
cases as well.
3. Positive scenarios:
This type of component testing expect a system to save a record without error.
4. Negative scenarios:
This type of component testing expect a system to give error.
5. **Restricted User:
Test whether a user with restricted access to the objects used in code sees
the expected behavior, i.e whether they can run the code or receive error
messages.
Error: Reference source not found
How is a test method defined?
A test method is defined as mentioned below:-
Syntax:

1static testMethod void testMethodName(){….. Code here ……..}


How is code coverage calculated?
Error: Reference source not found
Code coverage percentage is a calculation of the number of covered lines divided by the sum of the number of covered lines and uncovered
lines.
Note: Comments blank lines,System.debug() statements and curly brackets are
excluded

Multiple statements on one line are counted as one line for the purpose of code coverage. If(true){I=1}
Error: Reference source not found
Which classes are excluded from code coverage calculation?
Test classes (classes that are annotated with @isTest) are excluded from the code
coverage calculation.

How to retrieve code coverage information?


We can query these objects by using SOQL and the Tooling API to retrieve
coverage information. Using SOQL queries with Tooling API is an alternative way
of checking code coverage and a quick way to get more detail.
Error: Reference source not found

Unit Test Best Practices


• Aim to cover 100% Apex code lines with your Unit Tests. You know, only 75% is required, but aim for 100%
• Although it is not needed for Deployment, Use the System Assert Class Methods to compare the output of your Methods with the expected out-
put. Using the System Assert Class Methods, try to verify both positive and negative test scenario
• Use startTest and stopTest methods to avoid Governor Limits while testing actual code of functionality. And note that all test data should be
created outside and prior to calling these methods.
• If the class is Private and we are not able to access, we just need to use @testVisible annotation.
• Writing the test class for trigger we just use the DML and 1% coverage is enough.
• VSC: SFDX: Invoke Apex Tests > then choose the test class name or run all

Test classes best practices.


 Use @isTest at the Top for all the test classes
 Always put assert statements for negative and positive tests
 Use the @testSetup method to insert the test data into the Test class that will flow all over the test class.
 Always use Test.startTest() and Test.stopTest() doing this it will increase the governor limit of the salesforce. We also use this to increase the
governor's limit.
 Use System.runAs() method to test the functionality in user Context.
 Do not put (seeAllData = true) in test class otherwise, use it for exceptional cases.
 Avoid Using Hard Coding Ids anywhere in test Class or any apex class.
 Please make sure that each class has a minimum of 75% coverage and also the main functionality has been covered. If possible increase code
coverage up to 95%.
 All class methods must be tested for at least 200 records and keep the real scenarios in mind.

Code coverage best practice?


Some of the best practices are:
Code coverage should not depend on the existing data in the org, i.e. sellAllData **
should not be true
For testing trigger and batch class we should do bulk testing with at least 200
records.
Testing should be done for the entire scenario not only for the code coverage
Why code coverage differs between sandbox and production?
Sandbox and production environments often don’t contain the same data and
metadata, so the code coverage results don’t always match.
@isTest annotation ?
Use the @isTest annotation to define classes and methods that only contain code
used for testing our application.
SeeAllData=true annotation ?
Use the @isTest(SeeAllData=true) annotation to grant test classes and individual
test methods access to all data in the organization.
Error: Reference source not found
Considerations for the @IsTest(SeeAllData=true) Annotation?
If a test class is defined with the isTest(SeeAllData=true) annotation, this
annotation applies to all its test methods whether the test methods are defined
with the @isTest annotation or the test method keyword.
The isTest(SeeAllData=true) annotation is used to open up data access when
applied at the class or method level. However, using isTest(SeeAllData=false) on
a method doesn’t restrict organization data access for that method if the
containing class has already been defined with the isTest(SeeAllData=true)
annotation. In this case, the method will still have access to all the data in the
organization.
Error: Reference source not found
Why it is recommended to avoid using seeAllData=true?
Enabling this seeAllData = true exposes the data from the database to the test
class. It is recommended not to use as the code coverage of we apex class or
trigger will now be dependent on the data which is present in org and depending
upon that the code coverage may change
Why to create separate class for testing purpose?
Advantage of creating a separate class for testing as opposed to adding test
methods to an existing class is that classes defined with isTest don’t count against
our organization limit of 6 MB for all Apex code.
Error: Reference source not found
What are the considerations of using isTest annotation?
 Classes and methods defined as isTest can be either private or public.
 Classes defined as isTest must be top-level classes.
 One advantage to creating a separate class for testing is that classes defined with isTest don’t count against our organization limit of 6 MB for all
Apex code.
 We can also add the @isTest annotation to individual methods
 Classes defined as isTest can’t be interfaces or enums
 Methods of a test class can only be called from a running test, that is, a test method or code invoked by a test method, and can’t be called by a
non-test request.
 Test methods can’t be used to test Web service callouts. Instead, use mock callouts
 We can’t send email messages from a test method
 Methods of a public test class can only be called from a running test, that is, a test method or code invoked by a test method, and can’t be called
by a non-test request.
Error: Reference source not found
@testSetup annotation?

Methods that are annotated with @testSetup are used to create test records once
and then access them in every test method in the test class.
Test setup methods enable us to create common test data easily and efficiently.
By setting up records once for the class, we don’t need to re-create records for each test method.
Example: For example, we have a test class, It has two test methods and each
test method required 5 account records.So without creating 5 records for each
test method, we will create a new method with annotation @testSetup then
create only 5 account records. These records can access all test methods using
SOQL query in that test class.
Error: Reference source not found
What are the things to remember when we use @testSetup method?
All database changes are rolled back at the end of a test. We can’t use this method on records that existed before the test executed. We also can’t
use setCreatedDate in methods annotated with @isTest(SeeAllData=true), because those methods have access to all data in the org. The both
parameters (Id recordId, Datetime createdDatetime) of this method are mandatory.
What is the difference between testMethod and @isTest?
@isTest annotation is used to define the test classes which contains code to test
our application and these classes does not count against our overall code
coverage.
testmethod keyword is used to define apex test methods. Also test methods can
be defined in any apex class.
Error: Reference source not found
@testVisible annotation?
Some methods are declared as private so we won’t be able to call them outside
the class. However, sometimes we really want to be able to invoke it from a unit
test method.
To resolve this, we can mark the method with a @TestVisible annotation. Then
although it is still private, it is invokable from our unit test methods.
How is a class defined as a test class ?
Use @isTest annotation to define a test class.
Exception Handling

Exceptions
• In SF, a compile error is a Syntax error that won’t let you save your code. An Exception is a non-syntax error and can be anything
which interrupts the normal flow of the execution AKA Bug. An Exception is more of a Logical error, or an error that occurs when us-
ing certain data as opposed to others
• When an Exception can occur: For example, when trying to reference a null variable or when trying to insert a record without defin-
ing the mandatory fields
• Unhandled exceptions are exceptions that the code doesn’t catch and this is the default in SF, They cause your whole code execution
to stop and exit. Any DML operations that were processed before the exception are rolled back and not committed to the database. Get
logged in debug logs. End user sees an error message in the SF user interface
Handled exceptions are exceptions that the code does catch with writing extra code. They are handled in a way that will NOT stop the
whole code. Instead of throwing the exception and stopping the code, handled expectation can display a code that you type. Any DML
operations that were processed before the exception handling are committed to the database. Any code after the exception handling
block is processed

Try-Catch-Finally statement
• Can be used together to capture an exception and handle it gracefully without stopping the code. A Try block encloses the code where
exception may occur. A Catch block comes immediately after the try block and handles the exception and takes an argument of an
Exception Type variable. Can have 0 or more Catch blocks, each handling an exception type, and it will run based on the Exception
type
Can have 0 or more Finally blocks, that is always executed at the end, that allows to clean the code. At least 1 Catch or Finally block
must be present after Try
Note: Any statements in the try block occurring after the exception are skipped and aren’t executed.

• System Defined Exceptions: The exception class defines standard exceptions and contains methods for interrogating exceptions.
DMLException (when DML operations fail), ListException, NullPointer (when we try to reference a null variable) or generic
Exception
• Exception Methods: The Exception Class has many Methods that can be used with the Exception variable; getCause, getLineNumber,
getMessage, setMessage
• Catch Different Exception Types: We use more than 1 catch block top catch different exceptions to give different debug messages
for each exception type. When an Exception type is used and a Catch block is accessed, the code will then exit the whole block, so no
other Catch block will run.
• Best practice is to use several catch blocks: A catch block for each exception type and, A final catch block that catches the generic
Exception type and Always start from the most specific exception type, to the general
• Throw statement will throw an Exception and stop the execution. Similar to the addError() Method that we saw in Trigger, but
addError() method can only be used in triggers. We can use addError() method for only records that are available in Trigger Con-
text.
• Custom Exception Class: We cannot throw the System exceptions. Trying to do so will result in error: “Type cannot be constructed:
Exception”. To create our custom exception class, extend the built-in Exception class and make sure our class name ends with the
word Exception, such as “MyException” or “PurchaseException”. All exception classes extend the system-defined base class Excep-
tion, and therefore, inherits all common Exception methods. Once you create the custom Exception class, you can construct exceptions
from it, and use them in Throw

Aura
Where to use Lightning Components?
Answer: The Lightning components can be used in the following ways:
 Drag-and-drop components are meant for the Lightning App Builder and Community Builder.
 Add Lightning Components for Lightning Pages.
 Add Lightning Components for Lightning Experience Record Pages.
 Launch a Quick-action Lightning Component.
 Overrule the Lightning Component’s standard actions.
 Create custom applications
Error: Reference source not found
What are the components bundles used in the Lightning component?
Answer: The component bundles are enlisted in the below table:
Name of Component
Sl. No. Description
Bundle

1 Component This contains the mark up.

2 Controller This handles the events on the client side.

The developer can write the common logic inside helper used by different
3 Helper
controller methods, avoiding any sort of repetition
4 Style This is about the style of the component.

5 Documentation This records the component’s use.

6 Renderer This contains the default rendering behaviour of a component.

This icon in the Lightning App Builder gets displayed before the
7 SVG
component.

It not only helps in component reusability but also controls which all
8 Design
attributes need to exposed for the tools like Lightning App Builder.
Lightning Component Bundle includes:
● Component– A markup language is used for configuring the layout of the component.
● Controller– A JavaScript Controller is used for handling client-side processing or an apex controller is preferred for server-side
processing.
● Design File– A design file is used for describing the design-time behavior of the component being used in Lightning pages or in
Lightning App Builder.
● Documentation File–It is used to provide reference documents or sample code to users who have received your component.
● Helper–aims at storing reusable JavaScript functions which are handled by the controller. (server-side controller. It is usually used
for firing server-side actions and processing data or tasks. we can call Helper’s java-script function from a client-side controller or
renderer; It’s a JavaScript resource that defines the functions for all the component’s actions. When an event is fired, it may trig-
ger actions to change data and call rerender() on affected components. The rerender() function enables components to update
themselves based on updates to other components since they were last rendered)
● SVG File–enables you to include custom icons that can be used for reference further.
Lightning framework aligns with Salesforce user interface strategy to empower users with highly immersive and interactive
experience but involves a steep learning curve in comparison to Visualforce. Since application building is an inherent part of
Lightning, it is considered a bit more complex than Visualforce.
Both the frameworks encompass some pros and cons associated with them.

How does Salesforce 1 Mobile app use Lightning components?


Answer: We first create a Lightning tab for the Lightning component and subsequently include the tab in the navigation select list of Salesforce
1 mobile app and then the newly created tab to it.
Can a Lightning component be used that works with both interfaces – Mobile and Desktop?
Answer: It is possible to use Lightning components, Salesforce 1 mobile app, custom standalone apps directly in Lightning Experience as well
as template-based communities. Lightning components are used in the Visualforce page, for use in Salesforce Visualforce communities as well
as the classic environment.
Does Lightning Component work with Visualforce?
Answer: Yes, it does work with Visualforce.
Can Lightning be viewed as an MVC(model view controller) framework?
Answer: Not really. Lightning is a framework based on components.
Which Lightning components parts are server-side and which ones are client-side?
Answer: For the Lightning component, the client-side is the component page acting as a JavaScript controller, on the contrary, the server-side
acts as an Apex Controller.
Error: Reference source not found
What are the differences between Lightning and Visualforce components?
Answer: Visualforce components are page-centric and work is mostly server-based. Lightning components, on the other hand, are client-side
centric which accounts for their dynamic, mobile-friendly nature.
Can we create one component for inheriting style/CSS from the parent or we need to always define it in the Salesforce component?
Answer: Of course, we can do this. The styles can be inherited from parents and not necessarily defined in the component.
Error: Reference source not found
What is the purpose of using Aura: method Tag in Lightning?
Answer: The Aura: method tag can be used for defining a method for component API. So, there is no need to fire and handle a component event,
and it allows us to directly invoke the method in the component’s controller on the client-side. It also helps to simplify the code required for a
parent component to call a method on a child component that forms a part of the parent component.
Is it possible to include a Lightning component into another?
Answer: Yes, it is possible.Error: Reference source not found
What are the limits to the number of components used in an application?
Answer: There are no limits on the usage number of the components used in an application.
What are Aura Components? Why we use Aura: Namespace in the code?
Answer: Aura components are the self-contained and reusable units of an app. Components form the function units of Aura. Aura is the open-
source technology that works for Lightning components. The building blocks for the Aura: namespace helps to define the components and
applications.
Are there any CSS (styles) provided by Salesforce.com for Supported Lightning Components?
Answer: Yes, this is available in Salesforce Lightning Design System.
Are Lightning components meant only for mobile apps?
Answer: With a responsive design in mind, Lightning components are meant to be mobile-first. The components help to build responsive apps
faster for desktops, tablets, and mobile. Error: Reference source not found
Is it possible to include external JavaScript/CSS libraries in components?
Answer: Yes, multiple libraries can be used such as JavaScript/CSS libraries, jQuery, Bootstrap, etc from a local, static resource.
Is it possible to integrate lightning components with a framework such as Angular?
Answer: It is possible to insert the third-party code within a Visualforce page. The same Visualforce page is then put inside a Lightning
component. Then the same Lightning Component is used in another Lightning component that works for various environments.
Error: Reference source not found
Are there any options for Lightning Record Page Assignment?
Answer: It can be assigned in different ways, such as:
 Org default
 App Default (overrides the assignment at the org level)
 App Record Type Profile (overrides the assignment at the org and app level).
How to create a custom Lightning Record Page?
Answer: We can create it with the following steps:
Setup->App Builder in Quick Find Box->Select Lightning App Builder-> New->Record Page-> Name the page as <xxx>Select Opportunity-
>Choose Header, Sub header, Right Sidebar template and Click Finish.
Error: Reference source not found

What are the types of Lightning Record Pages in Salesforce?


Answer: Here are the types enlisted below:
 App Page
 Home Page
 Record Page
Error: Reference source not found
What are the attributes? What are the parameters required?
Answer: Attributes are the variables for storing values. The attribute is defined with a name, type, default, description, and access.
The <aura:attribute> tag is used that requires the values of name and type attributes.
However, name and type are the only required parameters. This is shown below:

Error: Reference source not found


Which interface to use if you want your component to be available for all pages?
Answer: You can use the flexipage:availableForAllPageTypes interface.
Which interface can be used to get the id of the record from the record Detail page?
Answer: The force:hasRecordId interface can be used for getting rid of the record from the record Detail page.
Which interface should be used to override a standard action?
Answer: Here you can make use of the Lightning:actionOverride interface.
Error: Reference source not found
Which interface is for using components in a quick action?
Answer: The interface used here is force:lightningQuickAction.
Which interface to use a component in the record home page?
Answer: The interface used here is flexipage:availableForRecordHome.
Which interface is used if you want a component to be used as a tab?
Answer: The interface used here is force:appHostable.
Error: Reference source not found
Why Lightning:isUrlAddressable interface is used?
Answer: The lightning:isUrlAddressable interface is used when navigating to the component and also when the component to be navigated
implements this interface.
How to find data changes using data handlers?
Answer: You can configure a component for invoking a change handler when the value of the attributes in one of the many components
changes.

Error: Reference source not found


What are the type of events into Salesforce Lightning component
 Application Event(Salesforce Document)
 Component Event
 System Event(Salesforce Document)
What is the basic difference between Application Event and Component Event
Answer: The major difference between application and component event is that component event is used in child to parent components and
application event can be used through out the application.

What are the propagation phases of Component Events?


A: Two phases are available for component event propagation after the event fires: capture phase and bubble phase.
What are the propagation phases of Application Events?
A: Three phases are available for application event propagation when the event fires: capture phase, bubble phase, and default phase.
What is the key difference between Application and Component Events?
A: The major differences are with what the events communicate. That said:
Component Events are applicable in parent-to-child communication in a hierarchy, f.e. if an update is made in the child component, it’ll be
signaled to the parent.
Application Events allow for communication regarding changes between various component types in different parts of a single app and aren’t
tied to hierarchical or direct connections.
Error: Reference source not found
In which cases should you use Application Events and when are Component Events preferable?
A: In general, it is considered good practice to give preference to Component Events over Application Events. Application Events are used for
signaling a message to a broader audience, whereas Component Events are tied to a hierarchy and can limit receiving the message to only those
components that should be notified about it.
Error: Reference source not found
Data Binding:
When you add a component in markup, you can use an expression to initialize attribute values in the component based on attribute values of the
container component. There are two forms of expression syntax, which exhibit different behaviors for data binding between the components.
This concept is a little tricky, but it will make more sense when we look at an example. Consider a c:parent component that has
a parentAttr attribute. c:parent contains a c:child component with a childAttr attribute that’s initialized to the value of the parentAttr attribute.
We’re passing the parentAttr attribute value from c:parent into the c:child component, which results in a data binding, also known as a value
binding, between the two components.

{#expression} (Unbound Expressions)


Data updates behave as you would expect in JavaScript. Primitives, such as String, are passed by value, and data updates for the expression in
the parent and child are decoupled.
Objects, such as Array or Map, are passed by reference, so changes to the data in the child propagate to the parent. However, change handlers in
the parent aren’t notified. The same behavior applies for changes in the parent propagating to the child.

<c:child childAttr="{#v.parentAttr}" />

{!expression} (Bound Expressions)

Data updates in either component are reflected through bidirectional data binding in both components. Similarly, change handlers are triggered
in both the parent and child components.

<c:child childAttr="{!v.parentAttr}" />

Important Topics:

**Attribute
**How to call Apex Server
**Attribute binding
**Components Events (Bubble and capture phase)
**Application Event(Bubble and capture phase)

**LDS (Please go through some predefined methods)


**SLDS
**Why to Use LDS
Error: Reference source not found

LWC
LWC data binding
Data binding in LWC is unidirectional. This is, the value of a property will propagate down, from parent to child, but never up, from child to
parent. The way to communicate from child to parent needs to be done in a different way, using events. The child component will fire an event,
that the parent component will listen to.
We can summarise this saying that, while in aura data binding was bidirectional, in LWC is unidirectional. This means, for sending information
from a parent to a child LWC, we use properties. While child components pass data up by firing events.

LWC Life Cycle of Events


A lifecycle hook is a callback method triggered at a specific phase of a component instance's lifecycle.
There are 5 events available LWC events:
1. connectedCallback - Called when the element is inserted into a document
2. constructor - Called when the component is created.
3. disconnectedCallback - Called when the element is removed from a document.
4. errorCallback - Called when component throws an error.
5. renderCallback - Called when need to update the UI. but will be called before or after connectedCallback.
Decorators on LWC or Reactive Operators

@api
To expose a public property, we decorate a field with @api . Public properties define the API for a component.
But To expose a public method, decorate it with @api . Public methods are part of a component’s API. To communicate down the containment
hierarchy, owner and parent components can call JavaScript methods on child components.
@track
Fields are reactive. If a field’s value changes, and the field is used in a template or in a getter of a property that’s used in a template, the
component rerenders and displays the new value.
For example, When a field contains an object or an array, there’s a limit to the depth of changes that are tracked. To tell the framework to observe
changes to the properties of an object or to the elements of an array, we decorate the field with @track .
@wire
Wire is generally used whenever is component load, at that moment I have to specify something, you know wire is configured with 3 things,
adapterID, adapter configuration and property which can be any object like Contact.
Adpater Id is the same id we are importing using import command. Adapter configuration is, If the import command require any configuration,
then we are using the configuration in adapter id.
Then we have property that will store all of the outputs we get from adapterid.
To read Salesforce data, Lightning web components use a reactive wire service. When the wire service provisions data, the component rerenders.
Components use @wire in their JavaScript class to specify a wire adapter or an Apex method.

Lightning message service


Lightning message service helps to communicate across the DOM, i.e., between the Visualforce pages, Aura components, and Lightning web
components, including components in a pop-out utility bar.
Once we tried putting a Visualforce page in Lightning Experience and used LMS to work with raw iframes and post Message to speak to
Lightning Components.
Publish on a Message Channel
To publish messages on a message channel from a Lightning web component, we include the @salesforce/messageChannel scoped module in
our component's JavaScript file and call the Lightning message service’s publish() function.
Subscribe and Unsubscribe from a Message Channel
To subscribe and unsubscribe from messages on a message channel, import the message channel from the @salesforce/messageChannel scoped
module into our Lightning web component. Call the Lightning message service’s subscribe() and unsubscribe() functions.
Advantages:
 you can opt in to whether you want your message channel to be available to other namespaces. That means communication on LMS is Secure by
Default. Components from other namespaces on the page won’t be able to snoop on your communication unless you allow them to
 Another benefit is at development time, if a Visualforce page or Lightning component tries to reference a message channel in a different names-
pace and that message channel is not “exposed,” that code won’t even compile. This has a huge benefit on your developer experience. You’ll im-
mediately know if your code will work at runtime.

Lightning Web Components Best practices

1) LWC component Bundle naming convention


Html file : Use camel case to name your component and use kebab-case to reference a component in the markup
JavaScript File : Java Script Class name should be in PascalCase
Bundle Component : use camelCase.
2) Apex
There are two way to call Apex class in LWC.
Imperatively and Wire
Wire a property
Wire a function
Wire Vs Imperatively :
As per Lightning component best practices use @wire over imperative method invocation. @wire fits nicely in the overall Lightning
Web Component reactive architecture. Salesforce is building some performance enhancement features that are only available with
@wire. But there are a few use cases,, that require you to use imperative Apex.

Wire Property Vs Wire Function :


Prefer wiring to a property. This best practice applies to @wire in general (not just to wiring Apex methods).

3) Lightning Data Service


As per LWC best practice use Lightning Data Service functions to create, record, and delete a record over invoking Apex methods.
Yes there are some use cases where you need multiple records then we can use Apex methods.

Lightning Data Service is built on top of User Interface API. UI API is a public Salesforce API that Salesforce uses to build Lightning
Experience. Like its name suggests, UI API is designed to make it easy to build Salesforce UI. UI API gives you data and metadata
in a single response

Give preference to user interface form-type in below order.


lightning-record-form : It is the fastest/most productive way to build a form.
lightning-record-view-form : If you need more control over the layout, want to handle events on individual input fields, or need to
execute pre-submission
@wire(getRecord) : If you need even more control over the UI, or if you need to access data without a UI
4) Event in LWC

There are typically 3 approaches for communication between the components using events.
 Communication using Method in LWC ( Parent to Child )
 Custom Event Communication in LWC(Child to Parent )
 Publish Subscriber model in LWC ( Two components which doesn't have a direct relation )
So, some recommendation for DOM Event.
No uppercase letters
No Spaces
use underscores to separate words
Don't prefix your event name with string "on".
<template>

<lightning-card title='Child Component'>


{greetings}
</lightning-card>

</template>
childEx.js

import { LightningElement, api, track } from 'lwc';

export default class ChildEx extends LightningElement {


@track greetings;
@api
handleBday(bdayDate){
this.greetings = 'Hey There Your Bday On ' + bdayDate;
}
}

5) Streaming API, Platform Event, Change Data Capture

The lightning/empApi module provides access to methods for subscribing to a streaming channel and listening to event messages.
All streaming channels are supported, including channels for platform events, PushTopic events, generic events, and Change Data
Capture events. This component requires API version 44.0 or later. The lightning/empApi module uses a shared CometD
connection. Example Code.

6) Debug LWC
Use Chrome pretty JS setting to see unminified JavaScript and Debug Proxy Values for Data. Here is example.
Enable Debug mode
It gives unminified Javascript
Console warnings
Pretty data structure
But Caution - it reduces performance of Salesforce, make sure its disabled in production
7) Use Storable Action
Use Storable Action, It will reduces call to Server. Syntax - @AuraEnabled(cacheable=true)

Caution: A storable action might result in no call to the server. Never mark as storable an action that updates or deletes data.
For storable actions in the cache, the framework returns the cached response immediately and also refreshes the data if it’s stale.
Therefore, storable actions might have their callbacks invoked more than once: first with cached data, then with updated data from
the server.

Is there any difference in how we add LWC component inside another LWC component and inside AURA component ?

LWC follows kebab case if you are adding any LWC component inside another component you will have to add in kebab case form
while in AURA it will be added without kebab case for example :
We have component with name “childLWCComponent”

In LWC it will be added as:


<PARENTWCCOMPONENT>
<c-child-l-w-c-component/> //Name of child LWC is 'childLWCComponent'
</PARENTWCCOMPONENT>

In Aura it will be added as:


<PARENTWCCOMPONENT>
<c:childLWCComponent/>
</PARENTWCCOMPONENT>
Can we add LWC in aura component?
Yes
----------------------------------------------------------------------
Can we add aura component in LWC?
No
Error: Reference source not found
What are lifecycle hooks in LWC ?
- Constructor : Called when the component is created.

- Connectedcallback : Called when the element is inserted into a document. This hook flows from parent to child. This is
similar to init() in aura.

- RenderedCallback : When component finishes loading DOM elements. This hook flows from child to parent.
<PARENTWCCOMPONENT>
<c-child-l-w-c-component/> //Name of child LWC is 'childLWCComponent'
</PARENTWCCOMPONENT>

- Disconnectedcallback : Called when the element/component is removed from a DOM. This hook flows from parent to child.
<PARENTWCCOMPONENT>
<IF {showSection =true}>
<c-child-l-w-c-component/>
</IF >
</PARENTWCCOMPONENT>

- Errorcallback : Called when a component throws an error.

Is wire method called multiple times during lifecycle of component ? (True / False)
True
----------------------------------------------------------------------

Communication between child-parent:


- parent to child in lwc:
variables/methods with @api annotation

- child to parent in lwc:


Events

Error: Reference source not found


----------------------------------------------------------------------
Can I evaluate expression in situation like <template if:true = {someVariable > 0}>
No. Use getter/setter or properties in LWC

//You can do this below:


valToChek =0;

get someVariable() {
if(this.valToChek >0)
return true;
else
return false;
}

<template if:true ={someVariable}


Error: Reference source not found
Can we do DML in method annotated with @AuraEnabled(cacheable= true)?
No
----------------------------------------------------------------------
What do you mean by cacheable = true annotations ?
First of all when you mark function as cacheable = true it can only retrieve data i.e. it cant have any DML.
It is used to improve component performance by quickly showing cached data from client side storage without waiting for server trip.
Error: Reference source not found
What is LMS (Lightning Message Service)?
LMS is defined as the standard publish-subscribe library that enables communication with DOM across Visualforce Pages, Aura
components, and Lightning Web Components (LWC) all can use it to publish message and listen to messages published by others.
Error: Reference source not found
Do we have application events in LWC?
We dont have application event as such in LWC like Aura rather we have LMS in LWC to communicate between components which
are not part of same hierarchy
Error: Reference source not found
LWC vs Aura
LWC is faster than Aura, because as it no longer requires the user to download the JavaScript and wait for the engine to compile it before
rendering the component.
It is possible to include LWC in Aura, vice-versa is not true.
Aura are built using both HTML and JavaScript, but LWC is built directly on the Web stack.
LWC one way data binding while aura is 2 way

You might also like