Salesforce Admin Preparation
Sections
1. Admin
2. Apex
3. VF Page
4. Aura
5. LWC
1.Admin:
1. What is a Profile?
A profile in Salesforce is a group/collection of settings and permissions
that define what a user can do in Salesforce.
A profile controls “Object permissions, Field permissions, User
permissions, Tab settings, App settings, Apex class access, Visualforce
page access, Page layouts, Record Types, Login hours & Login IP ranges.
Types of Profiles
1. Standard
2. Custom
Standard: Read Only, Standard User, Marketing User, Contract
Manager, Solution Manager & System Administrator.
Each of these standard ones includes a default set of permissions for all
the standard objects available on the platform.
Custom Profiles: Custom ones defined by us. They can be deleted if
there are no users assigned to that one.
2. What is Permission Sets
The Permission Set is like profile whatever you can manage with
profile same you can manage here.
But the main difference between these two is Every user should
have only profile but has one or more permission sets.
we can use permission set to grant additional access.
Example is assigning different permission sets to different
business users based on their requirement.
Custom Permission in Salesforce
Custom Permissions in Salesforce are used to give access to users for certain apps or
processes that you have configured, and which cannot be controlled by profile or
permission set directly.
A profile and a permission set control the users’ access to many entities such as
objects, fields, tabs, and Visualforce pages.
However, they cannot control a custom process that you have which is unique to
your business.
For e.g. only specific users should be able to edit an Opportunity once it is Closed
Won or save records bypassing validation rules.
To manage these granularities, you can leverage Custom Permissions in Salesforce.
They let you define checkpoints that can be assigned to users via permission sets or
profiles, in the same way how other permissions are assigned to users.
Process to Create a Custom Permission
Create a Custom Permission
Create a Permission Set
Add Custom Permission to Permission Set
Assign Permission Set to a User
Create a Validation Rule
Test Custom Permission
3. What is Role
It Controls the Record level access that define what data an user
can see in salesforce
You can increase data visibility through roles by using role
hierarchy in salesforce.
Role hierarchy determines what level of access a user will have
relative to other users in the organization.
Generally, you’ll have access to your data and the data of anyone
below you in the hierarchy.
4. What are the different levels of data access in Salesforce?
1) Organization level security
It is provided by Profiles. For your whole org, you can
maintain a list of authorized users, set password policies,
and limit logins to certain hours and locations.
2) Object level security.
It is provided by Profiles. You can Control CRUD
Operations on Objects by using profiles.
3) Field level security
It is provided by Profiles. You can restrict access to
certain fields, even if a user has access to the object.
4) Record level security.
You can allow users to view an object, but then restrict
the individual object records they’re allowed to see.
You can manage record-level access in these four ways.
i. Organization Wide Defaults
ii. Role Hierarchies
iii. Sharing Rules
iv. Manual Sharing
5.Organization Wide Defaults
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.
There are mainly four levels of access:
Public Read/Write/Transfer (only available of Leads and Cases)
Public Read/Write: All users can view, edit, and report on all records
(Given that they have object level permission).
Public Read/Only: All users can view and report on records, but only the
owner, and users above that role in the hierarchy, can edit them.
Private: Only the record owner, and users above that role in the
hierarchy, can view, edit, and report on those records.
6. Role Hierarchy
It Increases Data Visibility
User Roles are arranged in the form of hierarchy based
on the level they can be able to see data.
7. Sharing Rules
It Increases Data Visibility
Public Read/Only, Public Read/Write
We can create Sharing rules based on record owner and
field values in the record.
we can extend sharing access to user in public groups,
roles or territories.
8. Manual Sharing
Some external users, such as high-volume
Experience Cloud site users, don’t have roles and
can’t be used in sharing rules.
9. Apex Based Sharing
To access sharing programmatically, you must use
the share object associated with the standard or
custom object for which you want to share.
For example, AccountShare is the sharing object for
the Account object, ContactShare is the sharing
object for the Contact object.
Objects on the detail side of a master-detail
relationship do not have an associated sharing
object. The detail record’s access is determined by
the master’s sharing object and the relationship’s
sharing setting.
Apex Based sharing requires two arguments
recordId (which record is sharing) and
userorgroupid (To which user or groupid)
Needs to create one record on relatedsharingobject
with below Data.
i. parentID=recordId
ii. UserOrGroupId = userOrGroupId;
iii. AccessLevel = 'Read'
iv. RowCause =
Schema.Job__Share.RowCause.Ma
nual
10. What are the different types of Relationships in SFDC? What are
they?
Four Types of Relationship
Lookup
Master-Detail
Many to Many
Hierarchical
11. Lookup Relationship
There is a Look-up relationship between Account and
contact with ‘CascadeDelete’ property set as True. So, for
any relationship where the cascadeDelete is set to True a
child record is deleted when the parent is deleted.
Therefore, Account and Contact behave as master-detail in
business logic but on UI it is a lookup relationship.
12. Master Detail Relationship
Roll-up Summary fields. Roll-Up-Summary fields are
those which are used to summarize data with any
associated child object.
13. Many-to-Many Relationship
Many-Many Relationships between two objects can be
created.
Junction Object is used to create Many-Many
Relationships.
Junction object can also be called as Join Object.
Junction Object links each object in Many-Many
Relationships.
14. Junction Object
Two Master Detail Relationships needs to create on
One Object that object is Junction Object
Example Candidate (Master)-Job Application
(Detail)-Job Position (Master)
15. 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.
16. Can we create Master Detail relationship on existing records?
Yes, it is possible to create Master-Detail
Relationship on existing record. First, we must
create Look-Up relationship to a record then
convert it to master-Detail Relationship.
17. Governor Limits
1. Governor Limits which control how much data or how many
records you can store in the shared databases.
2. Because Salesforce is based on the concept of multi-tenant
architecture. In simple words, Salesforce uses a single database to
store the data of multiple clients/ customers.
3. To make sure no single client monopolizes the shared resources,
Salesforce introduced the concept of Governor Limits in
Salesforce which is strictly enforced by the Apex run-time engine.
Types Of Governor Limits in Salesforce
There is different type of governor limit in Salesforce. Here is list of different
type of governor limit in Salesforce.
1. Per-Transaction Apex Limits: These limits count for each Apex
transaction. For Batch Apex, these limits reset for each execution of a
batch of records in the execute method.
2. Force.com Platform Apex Limits: These limits aren’t specific to an
Apex Transaction and are enforced by the Lightning platform.
3. Static Apex Limits: Apex Limits that are applied across all transactions.
4. Size-Specific Apex Limits: Apex Limits related to the size of code.
5. Miscellaneous Apex Limits
6. Email Limits
7. Push Notification Limits
Per-Transaction Apex Limits
Synchronous
Asynchronous
Description Governor
Limit
Limit
Total number of SOQL queries issued1 100 200
Total number of SOSL queries issued in Salesforce 20
Total number of DML statements issued 150
Total number of records retrieved by a single SOSL
2000
query
Total number of records retrieved by SOQL queries 50000
Total number of records retrieved by
10000
Database.getQueryLocator
Total heap size 6 MB/12 MB
Maximum cumulative timeout for all callouts (HTTP
120 seconds
requests or Web services calls) in a transaction
Maximum number of Apex jobs added to the queue
50 1
with System.enqueueJob
10,000 60,000
Maximum CPU time on the Salesforce servers5
milliseconds milliseconds
18. Custom Settings and Custom Metadata
Custom Settings are like custom objects.
They are generally used to create custom sets of data and can
be associated with an organization, profile, or a specific user.
The visibility of the custom setting can be controlled by
marking it as public or protected.
Custom Settings data set can be used in Formula fields,
Validation rules, flows, Apex and SOAP API.
Custom Settings Custom Metadata Types
Custom Settings are also like
Custom metadata does not support
custom objects. You can either
Type Hierarchy type of data based on user
create a List based or hierarchy
profile or a specific user.
based custom setting.
Custom metadata types of data can be
Custom settings data cannot be
easily packaged and deployed. Metadata
Deployment deployed using packages or
types can also be deployed via Change
Metadata API/Change Sets.
Sets/Metadata API.
Relationship Custom settings do not support You can create lookups between Custom
Field relationship fields. Metadata objects.
It has a suffix of “__C” like custom
Suffix It has a suffix of “__mdt”
object
Custom metadata types are visible in
Custom setting data is not visible
Test Class test class without the “SeeAllData”
in test classes.
annotation.
You can perform CUD (Create, You cannot perform CUD (Create,
DML in Apex Update, Delete) operation on Update, Delete) operation on custom
custom setting in apex. metadata type in apex.
You can access custom setting With custom metadata types, you can
data using instance methods and issue unlimited (SOQL) queries for each
SOQL
can avoid SOQL queries to Apex transaction. But method is also
database available.
Summary
We recommend use custom setting for hierarchy-based data and use Custom
Metadata Types for list base data.
19. Types of Flows
There are 5 types of flows are available in Salesforce. They are
1. Screen Flow
a. It can be triggered by using Button or Action
b. If you click on Action on Object, it will ask Action Type select
flow and provide the label
c. If You Choose Button we need to provide Label, Name,
Behavior, Content Source
2. Auto launched Flow
3. Record-Trigged Flow
4. Platform Event -Trigged Flow
5. Scheduled Trigger Flow
20. Order of Execution
In Salesforce, this is the order in which actions execute:
1. System Validation Rules
2. Apex Before Triggers
3. Custom Validation Rules
4. Duplicate Rules
5. Apex After Triggers
6. Assignment Rules
7. Auto-Response Rules
8. Workflow Rules
9. Processes
10. Escalation Rules
11. Roll-Up Summary Fields
21. Apex Best Practices
Bulkify Your Code
Avoid SOQL/DML Queries in Loops
Avoid Hard-Code Id’s
Use a Single Trigger Per One Object
Querying Large Datasets
Use Database Methods While doing DML
Operations
Exception Handling in Apex code
Make Reusability of Apex Code
22. Asynchronous and Synchronous in Salesforce
i. A future method run as asynchronously.
ii. You can call a future method for executing long-running
operations, such as callouts to external Web services or any
operation you’d like to run in its own thread, on its own time.
iii. Each future method is queued and executes when system
resources become available.
iv. That way, the execution of your code doesn’t have to wait for the
completion of a long-running operation.
Future Method Syntax
global class MyClass
@future
public static void myFutureMethod(){ // Perform some operations }
Future Method Consideration
i. Methods with future annotation Must be static methods
ii. Can only return Void Type
iii. The Specified parameters must be primitive data types, arrays of
primitive data types, or collections of primitive data types
iv. Methods with future annotation cannot take Sobjects or objects as
arguments
v. A future method cannot invoke another future method
Why sObjects can’t be passed as arguments in the future method?
i. The reason why sObjects can’t be passed as arguments to future
methods is that the sObject might change between the time you call the
method and the time it executes.
ii. In this case, the future method will get the old sObject values and might
overwrite them.
iii. To work with sObjects that already exist in the database, pass the
sObject ID instead (or collection of IDs) and use the ID to perform a
query for the most up-to-date record.
What Is the Use of The Future Method in Salesforce?
There are many use cases when we can use the future methods in Salesforce.
i. Avoid the CPU time limit Error: To avoid the log running talk and
avoid the CPU time limit we can use the @Future method in Salesforce.
Learn more about Apex CPU Time Limit Exceeded.
ii. Callout from Trigger: As we know we cannot do the callout from the
trigger, but we can invoke callouts from triggers by encapsulating the
callouts in @future methods.
iii. Avoid Mixed DML operation: A Mixed DML operation error occurs
when you try to persist in the same transaction, change to a Setup
Object, and a non-Setup Object.
iv. You can also make use of future methods to isolate DML operations on
different sObject types to prevent the mixed DML error.
v. Higher governor limit: A benefit of using future methods is that
some governor limits are higher, such as SOQL query limits and
heap size limits.
Apex CPU Time Limit Exceeded
i. Salesforce has a timeout limit for transactions based on CPU usage.
ii. The apex CPU time limit exceeded means your transaction is taking too
much time to complete the code execution.
iii. Use Best Practices to resolve System.LimitException: Apex CPU time
Limit exceeded error in Salesforce.
Future Method Callouts Using @Future (Callout=True)
i. Example of a future method that makes a callout to an external service.
ii. Notice that the annotation takes an extra parameter (callout=true) to
indicate that callouts are allowed
What is CRON Expression?
I. Subscription schedules are shown as a cron expression.
II. A subscription's cron expression consists of six statements separated by
spaces using this syntax: Seconds Minutes Hours Day_of_month Month
Day_of_week .
How To Abort Jobs Through Anonymous Window
List<CronTrigger> listCronTrigger = [select Id, CronExpression, EndTime,
NextFireTime, OwnerId,PreviousFireTime, StartTime, State, TimesTriggered,
TimeZoneSidKey from CronTrigger where State = 'Waiting' or
State='Running'];
If (listCronTrigger.size() > 0)
for (Integer i = 0; i < listCronTrigger.size(); i++){
System.abortJob(listCronTrigger[i].Id);
System.debug('Job details ::'+String.valueOf(listCronTrigger[i]));
}}
Refresh Token & Access Token
A refresh token just helps you re-validate a user without them having to re-
enter their login credentials multiple times.
The access token is re-issued, provided the refresh token is a valid one
requesting permission to access confidential resources.
Accept application/json,
Accept-Encoding gzip, deflate,
Authorization Bearer 7ff04dd9-b5f2-376f-ac3a-
d094e571c500,
Content-Type application/json
Interview Questions:
Q. How to Restrict some category Record Access on Standard Objects
(Account,contact,Opportunity e.tc.)
A. Since We have no Restriction Rules on Standard Objects except Task. First ,
remove all records access on OWD, then provide access using sharing rules.
Reference Links
1. https://www.youtube.com/watch?v=53q3I-bJobk
2. https://salesforcediaries.com/2019/09/09/xml-package-to-
retrieve-metadata-from-org/
3. https://www.mirketa.com/apex-security-and-sharing/