[go: up one dir, main page]

100% found this document useful (1 vote)
153 views160 pages

Salesforce CRM Study Material No 2

The document discusses Salesforce CRM, including what CRM and cloud computing are. It then discusses what Salesforce CRM is, the different Salesforce cloud services, Salesforce CRM modules for training, Salesforce editions, how to create a developer org, licenses, profiles, roles, sharing models, apps, tabs, and how to create profiles, roles, apps and tabs in Salesforce.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
153 views160 pages

Salesforce CRM Study Material No 2

The document discusses Salesforce CRM, including what CRM and cloud computing are. It then discusses what Salesforce CRM is, the different Salesforce cloud services, Salesforce CRM modules for training, Salesforce editions, how to create a developer org, licenses, profiles, roles, sharing models, apps, tabs, and how to create profiles, roles, apps and tabs in Salesforce.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 160

SALESFORCE

What is CRM ?
SALESFORCE
CRM ➢ C-R-M stands for Customer Relationship
Management.
➢ It is used to manage and analyze customer
interactions and data throughout
the customer lifecycle.
➢ CRM works to increase profits by producing greater
sales volume.
2. What is Cloud Computing?
SALESFORCE
➢ Cloud computing is the delivery of computing
CRM services like servers, storage, databases, networking
and software over the Internet.

3. Types of Cloud Computing.


➢ IaaS (Infrastructure as a Service)
➢ PaaS (Platform as a Service)
➢ SaaS (Software as a Service)
What is Salesforce CRM ?
SALESFORCE ➢ Salesforce.com is a cloud computing and social
CRM enterprise software-as-a-service (SaaS) provider
based in San Francisco. It was founded in March
1999, in part by former Oracle executive Marc
Benioff.
5. Salesforce Cloud Services?
➢ Sales cloud
➢ Service Cloud
➢ Marketing Cloud
➢ Community Cloud
➢ Health Cloud etc…
What is Salesforce CRM ?
SALESFORCE ➢ Salesforce.com is a cloud computing and social
CRM enterprise software-as-a-service (SaaS) provider
based in San Francisco. It was founded in March
1999, in part by former Oracle executive Marc
Benioff.
5. Salesforce Cloud Services?
➢ Sales cloud
➢ Service Cloud
➢ Marketing Cloud
➢ Community Cloud
➢ Health Cloud etc…
• Salesforce CRM Modules for Training
SALESFORCE • Salesforce Administration
CRM • Salesforce Customization
• Sales Cloud
• Service Cloud
• Community Cloud
• Salesforce Integration
• Salesforce Lightning
• Development on IDE
• App Exchange
• Migration Tools
➢ Salesforce Editions
SALESFORCE ✓ Essentials
CRM ✓ Professional
✓ Enterprise
✓ Unlimited &
✓ Developer
NOTE Salesforce doesn’t provide technical support for
Developer Edition.
Link for Reference :
https://help.salesforce.com/articleView?id=overview_editi
on.htm&type=5
➢ Create salesforce developer org.
SALESFORCE ✓ Link : https://developer.salesforce.com/
CRM ✓ Click on Signup
✓ Enter all the details
✓ Click on Sign me up >
✓ Please check your email for confirmation
✓ Check the org details.
➢ What is licenses in salesforce ?
SALESFORCE • A user license entitles a user to different functionality within
CRM Salesforce and determines which profiles and permission sets
are available to the user.

To view a list of the active user licenses in your company, from


Setup, click Company Profile | Company Information. This
page lists the following for each type of user license:
• Status indicates the status of the license.
• Total Licenses indicates the number of licenses for which your
company is billed and that are available to you.
• Used Licenses is the number of licenses that you have
assigned to users.
• Remaining Licenses is the number of unused licenses.
➢ Types of licenses in salesforce.
SALESFORCE
Please follow the below link for guidance
CRM https://help.salesforce.com/articleView?id=users_licens
e_types_available.htm&type=5
➢ What is Profile in salesforce ?
SALESFORCE • Represents a user profile. A profile defines a user's permission to

CRM perform different functions within Salesforce.


Every profile Must be associated with a License. This defines what
the profile can do

you can retrieve and deploy access settings for the following
managed components in profiles and permission sets:Apex classes
• Custom apps
• Custom field permissions
• Custom object permissions
• Custom tab settings
• External data sources
• Record types
• Visualforce pages
➢ Types of Profile.
SALESFORCE • Standard profiles: By default, salesforce provides
CRM below standard profiles. We cannot delete standard
ones.
• 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 of 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
particular one.
➢ How to create a profile in salesforce?
SALESFORCE
Please follow the below link for guidance
CRM https://help.salesforce.com/articleView?id=admin_user
profiles.htm&type=5
➢ What is Role in salesforce?
SALESFORCE
Depending on your sharing settings, roles can control
CRM the level of visibility that users have into your Salesforce
data. Users at any given role level can view, edit, and
report on all data owned by or shared with users below
them in the role hierarchy, unless your sharing model for
an object specifies otherwise.
➢ How to create Role in salesforce?
Please follow the below link for guidance
https://help.salesforce.com/articleView?id=000001047
&language=en_US&type=1
➢ Difference between Profiles and Roles in salesforce?
SALESFORCE A profile contains user permissions and access settings
CRM that control what users can do within their organization.
Profiles control standard and custom
apps, tabs, permissions, Apex classes
and Visualforce pages, etc. users can view.

A role controls the level of visibility that users have into


your organization’s data. Users at any given role level can
view, edit, and report on all data owned by or shared
with users below them in the hierarchy, unless your
organization’s sharing model for an object specifies
otherwise.
➢ What is Sharing model in salesforce?
SALESFORCE
In Salesforce, you can control access to data at many
CRM different levels. For example, you can control the access
your users have to objects with object permissions.
Within objects, you can control the access users have to
fields using field-level security. To control access to data
at the record level, use sharing settings.

Please follow the below link for more details.


https://help.salesforce.com/articleView?id=managing_t
he_sharing_model.htm&type=5
➢ Difference between Profiles and Roles in salesforce?
SALESFORCE A profile contains user permissions and access settings
CRM that control what users can do within their organization.
Profiles control standard and custom
apps, tabs, permissions, Apex classes
and Visualforce pages, etc. users can view.

A role controls the level of visibility that users have into


your organization’s data. Users at any given role level can
view, edit, and report on all data owned by or shared
with users below them in the hierarchy, unless your
organization’s sharing model for an object specifies
otherwise.
➢ Apps
SALESFORCE
A salesforce application is a group of tabs that work
CRM as a unit to provide functionality. We can customize
existing app to match the way to work or build new
apps by grouping standard and custom tabs.

➢ How to create App?


Please follow the below link for guidance
https://help.salesforce.com/articleView?id=dev_tabsetc
reate.htm&type=5
➢ Tabs
SALESFORCE • Custom Object Tabs—For your custom object
CRM data. Custom Object Tabs display the data of your
custom object in a user interface tab. Custom object
tabs look and function just like standard tabs.
• Web Tabs—For other web content Custom Web Tabs
display any external Web-based application or Web
page in a Salesforce tab. You can design Web tabs to
include the sidebar or span across the entire page
without the sidebar.
• Visualforce Tabs—For Visualforce pages Visualforce
Tabs display data from a Visualforce page. Visualforce
tabs look and function just like standard tabs.
➢ How to create a tab?
SALESFORCE
Please follow the below link for guidance
CRM
https://help.salesforce.com/articleView?id=creating_cus
tom_object_tabs.htm&type=5
➢ What is custom object?
Objects are database tables that allow us to store data
specific to the organization in salesforce.
• . Standard Objects: The objects provided by
SALESFORCE salesforce.com is called standard objects.
CRM Examples of standard objects are accounts,
contacts, opportunities, Leads, products,
campaigns, cases, users, contracts, Report, and
dashboards, etc.
• 2. Custom Object: The objects created by us are
called custom objects. Custom objects store

information that is unique and important to your
• organization. Custom objects are the heart of any
• application. Custom objects provide a structure
• for sharing data.

• Creating Salesforce Custom Object
SALESFORCE • To create custom object go to Setup -> Build-> Create
CRM -> Objects ->Click on new custom object button and
enter label name, plural label and object name.
• And also enter Record Name according to the data
type. There are two data types available to create
record name, those are
• TEXT.
• Auto Number.
• And also we have the following optional features
while creating an object.
• Allow reports: If we check this check box, then only
these objects are available to create reports.
• Allow Activities: If we check this check box, then we
SALESFORCE can create activities on this object.
CRM • Track Field History: If we check this check box then
only we are to track fields. We can track up to 20 fields
for a single object.
• And also we following deployment Status
• In development: If we check this check box, this
object is still in development mode. This object is not
available for deployments.
• Deployed: After selecting this check box then only it
will be available for deployment.
• The following options are available only when creating
a custom object first time.
• After completing all the details click on save.
SALESFORCE
• If we do not select “Launch new custom tab wizard”
CRM from object creation page, the object will save
without tab appearance. In this case, we have to
create a tab for this object. If we select this check
box, the object will save and a tab will be created
and appeared.
➢ What is custom field in salesforce?
SALESFORCE
Fields you create on standard or custom objects are
CRM called custom fields.
➢ Create Custom Fields to capture your unique business
data by storing it in custom fields.
Please follow the below link for guidance
https://help.salesforce.com/articleView?id=adding_field
s.htm&type=5
➢ What is Page layout in salesforce?
SALESFORCE
Page layouts control the layout and organization of
CRM buttons, fields, s-controls, Visualforce, custom links, and
related lists on object record pages. They also help
determine which fields are visible, read only, and
required. Use page layouts to customize the content of
record pages for your users.
➢ How to create Page layout?
Please follow the below link for guidance
https://help.salesforce.com/articleView?id=customize_l
ayout.htm&type=5
➢ What is Record Type in salesforce?
SALESFORCE
Record types let you offer different business
CRM processes, picklist values, and page layouts to different
users. You might create record types to differentiate
your regular sales deals from your professional services
engagements, offering different picklist values for each .
➢ What is field dependency in salesforce ?
SALESFORCE
The value selected in the controlling field affects the
CRM values available in the dependent field. Adependent
field works in conjunction with a controlling field to
filter its values. We can define custom picklist fields as
controlling or dependent fields. Standard picklist filed
must be controlling fields.

Link for reference


https://help.salesforce.com/articleView?id=fields_defini
ng_field_dependencies.htm&type=5
➢ Types of relationships in salesforce ?
SALESFORCE
• Self-relationship
CRM
• Self-relationship is another example of a lookup
relationship. In Salesforce, we can use lookup
relationships to create self-relationship among
objects; we can have a maximum of 40 self-lookups.
➢ Types of relation ships in salesforce ?
SALESFORCE • Master-Detail (1:n)
CRM • A parent-child relationship in which the master object
controls certain behaviors of the detail object.
• When a record of the master object is deleted, its related
detail records are also deleted.
• The Owner field on the detail object is not available and is
automatically set to the owner of its associated master
record. Custom objects on the detail side of a
master-detail relationship cannot have sharing rules,
manual sharing, or queues, as these require
the Owner field.
• The detail record inherits the sharing and security settings
of its master record.
➢ Types of relation ships in salesforce ?
SALESFORCE
• Master-Detail (1:n)
CRM
• The master-detail relationship field is required on the
page layout of the detail record.
• By default, records can’t be reparented in
master-detail relationships. Administrators can,
however, allow child records in master-detail
relationships on custom objects to be reparented to
different parent records by selecting the Allow
reparenting option in the master-detail relationship
definition.
• You can define master-detail relationships between
custom objects or between a custom object and a
standard object. However, the standard object cannot
➢ Types of relation ships in salesforce ?
SALESFORCE
• Lookup Relationship (1:n)
CRM
• This type of relationship links two objects
together but has no effect on deletion or security.
Unlike master-detail fields, lookup fields are not
automatically required. When you define a lookup
relationship, data from one object can appear as a
custom related list on page layouts for the other
object. See the Salesforce online help for details.
• Child row not automatically deleted when a parent
row is deleted
• No inherited sharing.
• 25 lookup relation relationships allowed per object.
➢ Types of relation ships in salesforce ?
SALESFORCE
• Lookup Relationship (1:n)
CRM
• This type of relationship links two objects together but
has no effect on deletion or security. Unlike
master-detail fields, lookup fields are not
automatically required. When you define a lookup
relationship, data from one object can appear as a
custom related list on page layouts for the other
object. See the Salesforce online help for details.
• Child row not automatically deleted when a parent
row is deleted
• No inherited sharing.
• 25 lookup relation relationships allowed per object.
➢ Types of relation ships in salesforce ?
SALESFORCE
• How many relationships included in SFDC & What are
CRM they?
• We are having three types of relationships, they are
• Lookup Relationship (self /1:M)
• Master-Detail Relationship (1:M)
• Many-to-Many relationship
Link for Reference :
https://www.salesforcetutorial.com/object-relationship
s-in-salesforce/
https://subscription.packtpub.com/book/big_data_and_
business_intelligence/9781786463180/1/ch01lvl1sec13/
• What is workflow rule and Workflow actions?
SALESFORCE Many of the tasks you normally assign, the emails
CRM you regularly send, and other record updates are part
of your organization's standard processes. Instead of
doing this work manually, you can configure
workflow to do it automatically.
Workflow automates the following types of actions
based on your organization's processes: Tasks—
Assign a new task to a user, role, or record owner.
• Email Alerts—Send an email to one or more
SALESFORCE recipients you specify.
CRM • Field Updates—Update the value of a field on a
record.
• Outbound Messages—Send a secure, configurable
API message (in XML format) to a designated
listener.
• Before adding new action you need to deactivate
workflow rule and do the changes and then again
activate it.
• workflow already exists on object. Now user want
SALESFORCE to add time dependent workflow action to it but
CRM not able to get an option to select time
dependent action. What might be issue?
Evualation criteria is set to “created, and every time
it’s edited”
• What is queue?
A queue can hold a predefined set of objects and
• consists of a set of users. Any of the queue members
can pick up tasks assigned to the queue. Users or

Queues can be owners of records.
• While adding queue members to queue, you can add
users, public group, partner users, specify role of users

etc.
• What are approval process?
SALESFORCE Salesforce supports wizard based easy to configure
CRM approval process. After an object is selected, the
wizard guides the user through a step-by-step setup.
Approval process is triggered when a user clicks on
the "Submit for approval" button.
The approval process consists of the following steps
-
Process definition
• Initial submission actions
• Step definitions
• Final Rejection actions
• Final Approval actions
• Final Recall actions In workflow rule, action is
SALESFORCE triggered when a record meets an evaluation criteria.
CRM Workflow rules definition does not impact existing
records. Workflow rule gets applied to new
record creation or edits.
• Is it possible to create parallel approval process
(ability for multiple user to approve or reject a
record)?
Yes. Parallel approvalprocess allows specifying (upto
25) multiple approvers. The approver setting could
be set to unanimous, or first action. In unanimous
parallel approval process, all approvers must approve
a request, before it is considered as approved.
• 1. What is process builder?
SALESFORCE The Process Builder is a workflow tool that helps you
CRM easily automate your business processes by
providing a powerful and user-friendly graphical
representation of your process as you build it.
The Process Builder’s simple and powerful design
allows you to:
Create your processes using a convenient layout with
point-and-click efficiency.
• Create your whole process in one place rather than
using multiple workflow rules.
• Create processes by collaborating with different
teams in your business.
• Stop using Apex code to automate simple tasks.
SALESFORCE
• Automated processes in the Process Builder are
CRM based on records and consist of:
Criteria that determine when to execute action
groups.
• Immediate and scheduled actions to execute when
those criteria are met.
• Any change that causes a record to match the criteria
can automatically trigger the action group.
You can use the more powerful and flexible Process
Builder to perform the same actions as workflow.
The process builder doesn’t support outbound
messages, but you can easily create one yourself
with Apex. With the Process Builder, you can:
• Create a record
SALESFORCE
• Update any related record—not just the record or its
CRM parent
• Use a quick action to create a record, update a
record, or log a call
• Launch a flow—you can’t schedule this action with
workflow
• Send an email
• Post to Chatter
• Submit for approval

2. What should be the condition we need to specify
SALESFORCE in process builder to specify schedule actions?
CRM 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
• Do you want to execute the actions only when
specified changes are made to the record?


• s it possible to edit the process once it is
SALESFORCE activated?
CRM No, You need to clone and while cloning you can
create new process or create new version.

• What user permission is required to create edit and


view process?
“Manage Force.com Flow” AND “View AllData” in
profile.
• ow to troubleshoot the errors if any issue comes
SALESFORCE in process builder?
CRM Use the error messages that appear in the Process
Builder and the emails you receive when a process
fails to help solve problems that arise when you’re
working with processes. When all else fails, look at
the Apex debug logs for your processes.
Identifying Errors in the Process Builder
• The API names for criteria nodes and actions are
created in the background. When you create or
update processes, you might see error messages that
reference those names to help you identify
specifically where the problem occurred.
• Errors Received after a Process Starts Evaluating a
SALESFORCE Record
CRM • When a user performs an action that triggers a
process (such as creating a record) and that process
fails, the user sees a page with this error: “Workflow
Action Failed to Trigger Flow.” In addition, the
administrator who created the process receives an
email with more details.
• Using Debug Logs to Troubleshoot Processes
• Use debug logs to find detailed information about
your running processes after they finish running. For
example, if a process doesn’t seem to trigger when a
record meets the process’s criteria, or if you want to
understand the sequence of processes being
➢ What is flow in salesforce?
SALESFORCE
Flow is a powerful business automation tool that can
CRM manipulate data in Salesforce in a variety of ways. Such
application can be created right from the org’s setup
with just drag-drop/point-click. The ease of creating
flows makes it the number one go-to tool when it comes
to complex business requirements. It is not only easy to
create, but also it does not require any coding.
• There are 3 main “building blocks” of the flow, as
SALESFORCE seen in the screenshot:
CRM 1. Elements represent actions that are executed in the
flow;
2. Connectors define which path the flow takes;
3. Resources are the values that can be referenced
anywhere in the flow.
• What Features are included?
SALESFORCE
• On the left side of the Flow Designer, we get 3 tabs:
CRM palette; resources; explorer.
• Palette
• Palette gives access to a number of elements that
can be used to build the logic.
• – User Interface element Screen – Users can
interact with the Flow only through this element. It
lets the flow -collect information from the User and
pass it to other elements for processing
• – Logic Elements:
SALESFORCE
• – Decision – helps to determine the direction of the
CRM flow
• – Assignment – can set, change, add values of/to
variables
• – Loop – iterates through the values of a collection
variable
• – Wait – it becomes handy when the flow needs to
wait for an event to occur and define exactly how
the flow should behave in such event.
• – DML operations:
SALESFORCE
• – Record Create/Update/Lookup/Delete –the names
CRM speak for themselves. We can look for and Delete
records right in here (codeless Heaven for Admins).
• – Fast Create/Update/Lookup/Delete – these are
doing almost the same things as elements above but
by using only sObject variables. Using Fast elements
helps to bulkify the transaction. For example, if there
are 50 records that need to be updated, then it is
better to have Fast Update element to update 50
records at once, instead of having Record Update run
50 times, which increases API calls to the database.
• – Then we have Flow elements which list all the
flows that we have in our org. This helps to nest
• – Email Alerts – you know this one ? all email alerts
SALESFORCE that are being used in workflow rules and process
CRM builder in your org are included in this section
• – Quick Actions – yes, every single quick action that
has been created in your org is available within the
flows
• – At the end we have Apex and Static Actions
elements, in this part of the story we can work with
developers to use Flows and Apex coding together
to build some very powerful applications.
• Resources
SALESFORCE
• Resources – these are used to collect, store, and pass
CRM the data within or outside of the application. Based
on the demand we can choose one of the resources
below:
• Variables – changeable resources that can be
updated within the flow, or from outside (passing
value thru URL, Visualforce page). Used for passing
values throughout the flow;
• Collection variables – does the same trick as
SALESFORCE variables, except as many values within the same
CRM data type can be stored in this resource;
• – sObject variables – changeable resources where
we can store a record of a specific object type, when
stored in sObject variable all the fields of that record
can be accessed through the same variable;
• – sObject collection variables – stores multiple
records of a specified object type, this resource can
be used to Fast Delete, Fast Update, and Fast Create
records;
• – Stage (Beta) – newly added (Spring 18’) resource
that used to indicate the Stage of the process/flow
where the User at;
• – Constant – fixed value, can be used throughout
SALESFORCE flow;
CRM • – Formula – dynamically creates a value with the
help of other resources in the flow;
• – Text template – Formatted text, the best part of
this, html code can be used here (we will talk about it
in the future);
• – Choice – individual choice option;

• – Dynamic-record choice – a very powerful


resource. Shows a filtered list of Salesforce records
to the user, and stores one record that the user
chooses;
• – Picklist choice – Salesforce picklist or multi-select
picklist can be stored here for use in the flow;
• Note: Most of these resources are familiar to
SALESFORCE power-users but I would like to encourage you to
CRM research and learn more about sObject variables and
dynamic-record choice resources, those come in
handy in some pretty complex cases.
• Explorer :
• The Explorer is simply a library that includes all the
resources and elements that are being used in the
flow.
• How are Flows run?
SALESFORCE
• The awesomeness of the Flow does not end there,
CRM another perk is it can be run from almost
everywhere. However, to determine where to run
them we need to know the flow types, there 2 main
types:
• – Screen Flows – as the name suggests includes
screen element to gather information from a user,
this means that the flow type requires a user
interaction. This type of flow can be accessed in a
number of places: custom button; custom link; direct
URL, Visualforce Page, or Salesforce app
action. Note: Wait element is not available here.
• – Autolaunched – run in the background with no
SALESFORCE need of user interaction. It still can run everywhere
CRM that Screen Flows run, in addition, we can run it from
process builder and Apex. The official Visual
Workflow Guide says Workflow action is in pilot so I
guess it will be available for public use in the future,
and then we will be able to run autolaunched flows
even from workflow rules. Note: Screen element is
not available here.
• Conclusion
SALESFORCE
• To summarize, Flows include a lot of powerful
CRM features which would be useful in every single org.
This post is the first in a series, with the purpose of
familiarizing you with Flows and to show what their
capabilities are. In upcoming posts, we will be talking
about flows’ best practices and we will be sharing
real-life projects.
• Collection in salesforce :
SALESFORCE
Collections is a type of variable that can store multiple
CRM number of records. For example, List can store multiple
number of Account object's records. Let us now have a
detailed overview of all collection types.
• Types of Collections:
SALESFORCE
• There are three types of Salesforce collections. They
CRM are
• List
• Set
• Map
List:
List is an ordered collection of elements which will
allow duplicates.
Syntax
SALESFORCE
List<datatype> listName = new List<datatype>();
CRM
List Methods :
list.add() method adds the values (items) to the list.
• List<String> colors =new List<String>();
• colors.add('Red');
• colors.add('White');
• colors.add('Black');
List<String> colors =new
SALESFORCE List<String>{'Red','White','Black’}
CRM String getcolor = colors.get(1); // we get the value is
'White' in to getcolor veriable.
colors.set(1,'Green'); // List has value at index ' 1 ' is
White is changed to Green.
colors.size(); // Gives the size of colors list is ‘2’
colors.clear();
public class ContactInsertion {
SALESFORCE
List<contact> contactList = new List<contact>();
CRM
public void methodName() {
for(integer i=0; i<100 ; i++ ) {
contact cont = new contact(lastname = 'contact' + i);
contactList .add(cont);
}
insert contactList ;
}
}
SET:
SALESFORCE
Set is an unordered collection of elements which will
CRM not allow duplicates.
Set<datatype> setName = new Set<datatype>();
• data type allows only primitive datatypes and
SObjects.
• We cannot get the retrieve the data based on index
because set does not have index.
MAP:
SALESFORCE
Map stores key-value pairs.
CRM
Map<datatype_key,datatype_value> mapName =
new Map<datatype_key,datatype_value>();
map.put(key,value);
map.get(key);
map.keySet();
map.values();
map.size();
public class AccountMapPopulation{
SALESFORCE
CRM
• // Creating map with account id and account object

• map <Id,Account> accountIdMap =new
map<Id,Account>();

• public void methodName(){


// creating the accounts
SALESFORCE • account acc1 = new account (name ='account1' ,
CRM industry = ' Banking');
• • account acc2 =new account(name =' account2' ,
industry = 'Agriculture');
• account acc3 = new account(name='account3' ,
industry='Banking');


• // populating the map with account id and account
object
• accountIdMap .put(acc1.id,acc1);
SALESFORCE
• accountIdMap .put(acc2.id,acc2);
CRM
• accountIdMap .put(acc3.id,acc3);

•}

•}
• What is Apex trigger in salesforce?
SALESFORCE
A trigger is the piece of code that executed before and
CRM after a record is Inserted/Updated/Deleted from the
force.com database.
Syntax :
• Trigger <trigger name> on <Object name> (trigger
Events) {
• // Implement the Logic here
•}
• Types of Triggers:
SALESFORCE – Before Triggers
CRM – After Triggers
• Before Trigger: Before triggers are used to perform
the logic on the same object and specifically we
cannot use the DML operation (Insert, update,
delete) on these triggers. These triggers fired before
the data saved into the database.
• After Trigger: After triggers are used to perform the
logic on the related objects and these triggers are
used access the fields values that are created by
system (Ex: CreatedBy, LasteModifiedBy , Record Id
etc..).
• Bulk Triggers:
SALESFORCE By default, every trigger is a bulk trigger which is used
CRM to process the multiple records at a time as a batch.
For each batch of 200 records.
• All the trigger context variables prefixed with
“Trigger.” (Ex: Trigger.isInsert, etc..)
• isInsert: Returns true if the trigger fired due to insert
operation
• isUpdate: Returns true if the trigger fired due to the
update operation.
• isDelete: Returns true if the trigger fired due to
delete operation.
• isBefore: Returns true if the trigger fired before the
record saved.
• isAfter: Returns true if the trigger fired after the
SALESFORCE record saved.
CRM • New: Returns a list of the new version of sObject
records.
• Old: Returns a list of an old version of sObject
records.
• NewMap: Returns a map of a new version of sObject
records. (map stored in the form of
map<id,newRecords>)
• OldMap: Returns a map of an old version of sObject
records. (map stored in the form of map<id,
oldRecords>)
• Size: Returns an integer (total number of records
SALESFORCE invoked due to trigger invocation for the both old
CRM and new)
• isExecuting: Returns true if the current apex code is a
trigger.
SALESFORCE
CRM Trigger Event Trigger.New Trigger.newMap Trigger.Old Trigger.OldMap
Before Insert Yes No No No
Before Update Yes Yes Yes Yes
Before Delete No No Yes Yes
After UnDelete Yes Yes No No
After Insert Yes Yes No No
After Update Yes Yes Yes Yes
After Delete No No Yes Yes
• Trigger Context Variable considerations:
SALESFORCE – Trigger.Old is always read-only
CRM – We cannot delete trigger.new
– In before triggers, trigger.new can be used to
update the fields on the same object.
– In After trigger, we get a runtime exception when
the user tries to modify the fields in the same object.
• What is Apex class in salesforce?
SALESFORCE
As in Java, you can create classes in Apex. A class is a
CRM template or blueprint from which objects are created.
An object is an instance of a class. For example, the
PurchaseOrder class describes an entire purchase
order, and everything that you can do with a purchase
order. ... A class can contain variables and methods.

In Apex, you can define top-level classes (also called


outer classes) as well as inner classes, that is, a class
defined within another class. You can only have inner
classes one level deep. For example:
• public class myOuterClass {
SALESFORCE
• // Additional myOuterClass code here
CRM
• class myInnerClass {
• // myInnerClass code here
• }
•}
• Class Variables
SALESFORCE
• To declare a variable, specify the following:
CRM
• Optional: Modifiers, such as public or final, as well
as static.
• Required: The data type of the variable, such as String
or Boolean.
• Required: The name of the variable.
• Optional: The value of the variable.
• o define a method, specify the following:
SALESFORCE
• Optional: Modifiers, such as public or protected.
CRM
• Required: The data type of the value returned by the
method, such as String or Integer. Use void if the
method does not return a value.
• Required: A list of input parameters for the method,
separated by commas, each preceded by its data type,
and enclosed in parentheses (). If there are no
parameters, use a set of empty parentheses. A
method can only have 32 input parameters.
• Required: The body of the method, enclosed in braces
{}. All the code for the method, including any local
• variable declarations, is contained here.
SALESFORCE
• Use the following syntax when defining a method:
CRM
• [public | private | protected | global] [override]
[static] data_type method_name
• (input parameters)
•{
• // The body of the method
•}
• What is VF page in salesforce ?
SALESFORCE
• Visualforce pages are webpages that belong to
CRM Salesforce. These webpages are created using a
unique tag-based Mark-up language. It is similar to
HTML but it's primary use is to access, display and
update the organization’s data. The page is accessed
by using a URL similar to that of a traditional
webserver page.
• Each tag in visual force language corresponds to some
user interface component like section of a page, a list
view or a field of an object. Interestingly, it can be
easily mixed up with HTML markup, CSS style and Java
libraries, etc.
• What is VF page in salesforce ?
SALESFORCE
• Visualforce pages are webpages that belong to
CRM Salesforce. These webpages are created using a
unique tag-based Mark-up language. It is similar to
HTML but it's primary use is to access, display and
update the organization’s data. The page is accessed
by using a URL similar to that of a traditional
webserver page.
• Each tag in visual force language corresponds to some
user interface component like section of a page, a list
view or a field of an object. Interestingly, it can be
easily mixed up with HTML markup, CSS style and Java
libraries, etc.
• Creating a Visualforce Page
SALESFORCE
• Go to the link developer console → File → New →
CRM Visualforce page. The new window opens asking for a
page name. Let us now call it HelloworldPage. Let us
now write the code as shown in the following diagram
https://developer.salesforce.com/docs/atlas.en-us.pag
es.meta/pages/pages_quick_start_hello_world.htm
• VF Page Creation :
SALESFORCE
<apex:page standardController="Account">
CRM
<apex:pageBlock title="Hello {!$User.FirstName}!">
You are viewing the {!account.name} account.
</apex:pageBlock>
<apex:detail subject="{!account.ownerId}"
relatedList="false" title="false"/>
</apex:page>
VF Page Creation :
SALESFORCE
CRM <apex:page standardController="Account">
Hello {!$User.FirstName}!
</apex:page>

<apex:page standardController="Account">
<apex:pageBlock title="Hello {!$User.FirstName}!">
You are viewing the {!account.name} account.
</apex:pageBlock>
<apex:detail/>
</apex:page>
<apex:page standardController="Account"
SALESFORCE showHeader="true"
CRM tabStyle="account" >
<style>
.activeTab {background-color: #236FBD; color:white;
background-image:none}
.inactiveTab { background-color: lightgrey;
color:black;
background-image:none}
</style>
<apex:tabPanel switchType="client"
selectedTab="tabdetails"
id="AccountTabPanel" tabClass='activeTab'
SALESFORCE
inactiveTabClass='inactiveTab'>
CRM
<apex:tab label="Details" name="AccDetails"
id="tabdetails">
<apex:detail relatedList="false" title="true"/>
</apex:tab>
<apex:tab label="Contacts" name="Contacts"
id="tabContact">
<apex:relatedList subject="{!account}"
list="contacts" />
</apex:tab>
<apex:tab label="Opportunities"
name="Opportunities"
SALESFORCE
id="tabOpp">
CRM
<apex:relatedList subject="{!account}"
list="opportunities" />
</apex:tab>
<apex:tab label="Open Activities"
name="OpenActivities"
id="tabOpenAct">
<apex:relatedList subject="{!account}"
list="OpenActivities" />
</apex:tab>
<apex:tab label="Notes and Attachments"
name="NotesAndAttachments"
SALESFORCE id="tabNoteAtt">

CRM <apex:relatedList subject="{!account}"


list="CombinedAttachments" />
</apex:tab>
</apex:tabPanel>

</apex:page>
Redirecting to a Standard Object List Page
• For buttons or links that navigate a user to a standard
tab, you can redirect the content to present a list of
SALESFORCE
standard objects.
CRM
• • Create a Visualforce page with the following markup:
<apex:page action="{!URLFOR($Action.Account.List,
$ObjectType.Account)}"/>
<apex:page standardController="Account">
<apex:form>
SALESFORCE <apex:pageBlock title="Hello {!$User.FirstName}!">
CRM
You are viewing the {!account.name} account.
<p/>
Change Account Name: <p/>
<apex:inputField value="{!account.name}"/> <p/>
<apex:commandButton action="{!save}"

value="Save New Account Name"/>


</apex:pageBlock>
</apex:form>
</apex:page>
<apex:page standardController="Contact">
<apex:form>
SALESFORCE <apex:pageBlock title="Quick Edit:
CRM {!Contact.Name}">
<apex:pageBlockSection title="Contact Details"
columns="1">
<apex:inputField value="{!Contact.Phone}"/>
<apex:outputField
value="{!Contact.MobilePhone}"
label="Mobile #"/>
<apex:inputText value="{!Contact.Email}"
label="{!Contact.FirstName + '’s Email'}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}"
SALESFORCE value="Save"/>

CRM </apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page

https://Salesforce_instance/apex/myPage?id=enterid
The label attribute can be set on the following
Visualforce components:

SALESFORCE <apex:inputCheckbox>

CRM <apex:inputField>
<apex:inputSecret>
<apex:inputText>
<apex:inputTextarea>
<apex:outputField>
<apex:outputText>
<apex:selectCheckboxes>
<apex:selectList>
<apex:selectRadio>
<apex:form>

<!-- other form elements ... -->


<apex:outputPanel id="locationPicker">

<apex:outputField value="{!Location.country}">

SALESFORCE <apex:inlineEditSupport event="ondblClick" />

CRM </apex:outputField>

<apex:outputField value="{!Location.state}">

<apex:inlineEditSupport event="ondblClick" />

</apex:outputField>

<apex:outputField value="{!Location.city}">

<apex:inlineEditSupport event="ondblClick" />

</apex:outputField>

</apex:outputPanel>

<!-- ... -->

<apex:commandButton value="Refresh Picklists" reRender="locationPicker" />

</apex:form>
Related list :

<apex:page standardController="MyLookupObject c">


SALESFORCE <apex:relatedList list="MyChildObjects r" />
CRM
</apex:page>

PDF Convert:
<apex:page standardController="Account"
renderAs="pdf" applyBodyTag="false">
<head>
<style>
body { font-family: 'Arial Unicode MS'; }
.companyName { font: bold 30px; color: red; }
</style>
</head>
<body>
SALESFORCE <center>
CRM <h1>New Account Name!</h1>
<apex:panelGrid columns="1" width="100%">
<apex:outputText value="{!account.Name}"
styleClass="companyName"/>
<apex:outputText
value="{!NOW()}"></apex:outputText>
</apex:panelGrid>
</center>
</body>
</apex:page>
Building a Table of Data in a Page
Some Visualforce components, such as
SALESFORCE <apex:pageBlockTable> or <apex:dataTable>,
CRM allow you to display information from multiple records
at a time by iterating
over a collection of records. To illustrate this concept,
the following page
uses the <apex:pageBlockTable> component to list the
contacts associated with
an account that is currently in context:
Building a Table of Data in a Page
SALESFORCE <apex:page standardController="Account">
CRM <apex:pageBlock title="Hello {!$User.FirstName}!">
You are viewing the {!account.name} account.
</apex:pageBlock>
<apex:pageBlock title="Contacts">
<apex:pageBlockTable value="{!account.Contacts}"
var="contact">
<apex:column value="{!contact.Name}"/>
<apex:column value="{!contact.MailingCity}"/>
<apex:column value="{!contact.Phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
https://Salesforce_instance/apex/myPage?id=001x000
xxx3Jsxb
SALESFORCE
CRM Editing a Table of Data in a Page
In the last tutorial, you built a table of data. Using
<apex:inputField>
in the data table columns, you can create a table with
editable fields.
Using <apex:commandButton> you can save the data
you change. Any message (
such as Saving) is automatically displayed with the
<apex:pageMessages> tag.
The following page creates a page that enables you to
edit a series of Industry types at the same time:
https://Salesforce_instance/apex/myPage?id=001x000
xxx3Jsxb
SALESFORCE
CRM Editing a Table of Data in a Page
In the last tutorial, you built a table of data. Using
<apex:inputField>
in the data table columns, you can create a table with
editable fields.
Using <apex:commandButton> you can save the data
you change. Any message (
such as Saving) is automatically displayed with the
<apex:pageMessages> tag.
The following page creates a page that enables you to
edit a series of Industry types at the same time:
<apex:page standardController="Account" recordSetVar="accounts"

tabstyle="account" sidebar="false">

<apex:form>

<apex:pageBlock >
SALESFORCE <apex:pageMessages />

CRM <apex:pageBlockButtons>

<apex:commandButton value="Save" action="{!save}"/>

</apex:pageBlockButtons>

<apex:pageBlockTable value="{!accounts}" var="a">

<apex:column value="{!a.name}"/>

<apex:column headerValue="Industry">

<apex:inputField value="{!a.Industry}"/>

</apex:column>

</apex:pageBlockTable>

</apex:pageBlock>

</apex:form>

</apex:page>
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_q
uick_start_query_params_getting.htm

SALESFORCE
CRM
SALESFORCE
CRM • PageBlockTable:
• PageBlockTable should be define inside pageblock or
pageblocksection.
• PageBlockTable uses standard styles sheets to design
a visualpage.
• It has the required attribute "value".
• Column headers will be displayed automatically.
<!-- Page: -->

<apex:page standardController="Account">
<apex:pageBlock title="My Content">

SALESFORCE
<apex:pageBlockTable value="{!account}" var="item">

<apex:column value="{!item.name}"/>
CRM </apex:pageBlockTable>

</apex:pageBlock>

</apex:page>

--
• What is custom controller? why we go for custom
controllers?
• Standard controllers provides only built in standard
SALESFORCE functionality to visualforce pages, such as Save, Edit,
CRM Cancel & Delete etc….
• We cannot customize/develop our own functionality
by using standard controllers. By using custom
controllers we can write our own functionality or
override existing functionality. Custom controller is
an Apex Class developed by us. See the below
syntax to define custom controller in visualforce
page.
• <apex:page Controller=”ControllerName”>
• What is controller extension? Controller extension is
custom/additional behavior to standard controllers.
Extension is an apex class. We can add number of
extensions to visualforce page. See below syntax to
• <apex:page Controller=”ControllerName”
extensions=”Class1, Class2,..”>
• We can use Stnadard controller/ Custom Controller
SALESFORCE and extensions at a time. But we cannot use
CRM Standard controller & Custom controller at a time.
See below syntax to understand.
• <apex:page standardController=”ControllerName”
extensions=”Class1, Class2,..”> Correct
• <apex:page Controller=”MYControllerName”
extensions=”Class1, Class2,..”> Correct syntax
• <apex:page
standardController=”MYControllerName”
Controller=”MyController”> Wrong
• Controller Extension

• public class myControllerExtension {

SALESFORCE • private final Account acct;

// The extension constructor initializes the private member


CRM

• // variable acct by using the getRecord method from the standard


Ii • // controller.

• public myControllerExtension(ApexPages.StandardController
stdController) {

• this.acct = (Account)stdController.getRecord();

• }

• public String getGreeting() {

• return 'Hello ' + acct.name + ' (' + acct.id + ')';

• }

• }
<apex:page standardController="Account"
extensions="myControllerExtension">

• {!greeting} <p/>

• <apex:form>
SALESFORCE • <apex:inputField value="{!account.name}"/> <p/>

CRM • <apex:commandButton value="Save" action="{!save}"/>


• • </apex:form>

• </apex:page>

Custom Controller Existing functionality

• – We can override existing functionality


• – We can create new functionality.
• – We can customize navigation.
• – We can use HTTP callouts & Web Services
• – We can have control for how information is
accessed on the page.
Example :

&lt;apex:page Controller="AddmultipleAccountsController"&gt;

&lt;apex:form &gt;

&lt;apex:pageBlock &gt;

&lt;apex:pageBlockTable value="{!listAccount}" var="acc"&gt;

SALESFORCE &lt;apex:column headerValue="Account Name"&gt;

&lt;apex:inputField value="{!acc.Name}"/&gt;

CRM &lt;/apex:column&gt;

&lt;apex:column headerValue="Account Number"&gt;

&lt;apex:inputField value="{!acc.AccountNumber}"/&gt;

&lt;/apex:column&gt;

&lt;apex:column headerValue="Account Type"&gt;

&lt;apex:inputField value="{!acc.Type}"/&gt;

&lt;/apex:column&gt;

&lt;apex:column headerValue="Industry"&gt;

&lt;apex:inputField value="{!acc.Industry}"/&gt;

&lt;/apex:column&gt;

&lt;/apex:pageBlockTable&gt;

&lt;apex:pageBlockButtons &gt;

&lt;apex:commandButton value="Add one more account" action="{!addAccount}"/&gt;

&lt;apex:commandButton value="Save Accounts" action="{!saveAccount}"/&gt;

&lt;/apex:pageBlockButtons&gt;

&lt;/apex:pageBlock&gt;

&lt;/apex:form&gt;

&lt;/apex:page&gt;
Example :

&lt;apex:page Controller="AddmultipleAccountsController"&gt;

&lt;apex:form &gt;

&lt;apex:pageBlock &gt;

&lt;apex:pageBlockTable value="{!listAccount}" var="acc"&gt;

SALESFORCE &lt;apex:column headerValue="Account Name"&gt;

&lt;apex:inputField value="{!acc.Name}"/&gt;

CRM &lt;/apex:column&gt;

&lt;apex:column headerValue="Account Number"&gt;

&lt;apex:inputField value="{!acc.AccountNumber}"/&gt;

&lt;/apex:column&gt;

&lt;apex:column headerValue="Account Type"&gt;

&lt;apex:inputField value="{!acc.Type}"/&gt;

&lt;/apex:column&gt;

&lt;apex:column headerValue="Industry"&gt;

&lt;apex:inputField value="{!acc.Industry}"/&gt;

&lt;/apex:column&gt;

&lt;/apex:pageBlockTable&gt;

&lt;apex:pageBlockButtons &gt;

&lt;apex:commandButton value="Add one more account" action="{!addAccount}"/&gt;

&lt;apex:commandButton value="Save Accounts" action="{!saveAccount}"/&gt;

&lt;/apex:pageBlockButtons&gt;

&lt;/apex:pageBlock&gt;

&lt;/apex:form&gt;

&lt;/apex:page&gt;
• public class AddmultipleAccountsController {

• Account account = new Account();

• public list<Account> listAccount{ get; set; }

SALESFORCE • public AddmultipleAccountsController() {

CRM • listAccount=new list<Account>();

• listAccount.add(account);

• }

• Public void addAccount() {

• Account acc = new Account();

• listAccount.add(acc);

• }

• public PageReference saveAccount() {

• for(Integer i=0; i<listAccount.size(); i++) {

• insert listAccount;

• }

• return Page.Allaccountssaved; // I am returning another vf page here.

• }

• }

• DataTable:

SALESFORCE
• No need to write inside pageblock or
CRM pageblocksection.
• There is no required value.
• The data can be displayed using custom style
sheets.
• we need to specify column headers explicitly.
• Visualforce page:
<apex:page controller="sample" sidebar="false" >
SALESFORCE <style type="text/css">
CRM .outBorder
{
border:3px outset black;
}

.inBorder
{
border-top:3px dotted black;
border-left:3px dotted black;
}
</style>
<apex:pageBlock title="Pageblock Table">
<apex:pageblockTable value="{!acc}" var="a">
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Name}"/>
</apex:pageblockTable>
• <apex:pageBlock title="Data Table">
<apex:dataTable value="{!acc}" var="a"
styleClass="outBorder" width="550px">
<apex:column styleClass="inBorder">
SALESFORCE <apex:facet name="header">Account
CRM Name</apex:facet>
<apex:outputText
>{!a.Name}</apex:outputText>
</apex:column>
<apex:column styleClass="inBorder">
<apex:facet name="header">Account
Number</apex:facet>
<apex:outputText
>{!a.AccountNumber}</apex:outputText>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
</apex:page>
• Apex Controller:

public with sharing class sample


{
SALESFORCE
CRM public List<Account> acc {get;set;}
public sample()
{

acc = [SELECT Name, AccountNumber FROM


Account];
}

}
• What is Apex Class?

A class is the group of variables and methods.


SALESFORCE
CRM We can createa class in Salesforce in different ways. See the
below post toknow about apex class.

• Data types are used to define variables and methods in


classes. In Apex, all variables & expressions have one of the
below data types. Those are

• Primitive data types (Integer, Boolean, String, …… etc.)


• Enum (an enumerated list)
• sObjects (sObject, or Account, contact, object c….)
• Collection (list, set, map)

• Null (for the null constant. Which can be assigned to any


variable.

• An object created by the user – or system-defined classes.


• Static keyword is used to define static variables
to store data that is shared within the class.
• – Static variables are not memory constants.
SALESFORCE – All instances of the same class share a single copy
CRM of the static variable.
– This can be a technique used for setting flags to
prevent recursive triggers.
Public Class Demo{
public Static String Name='Google';
public String Email='Google@gmail.com';
}

we can access the Name by using below statement.

Demo.Name
to Access Email we need create the object.

SALESFORCE Demo obj=new Demo();


CRM obj.Email;

• What is final keyword?


• Final keyword is used to define constants – this
indicates that the variable can only be assigned
once, either in the declaration itself or with a static
initializer method if the constant is defined in the
class.
• Example :
private final Integer j=10;
• Apex allows you to use the private, protected,
public,and global access modifiers when
defining methods and variables.
SALESFORCE
CRM • While triggers and anonymous blocks can also use
these access modifiers, they are not as useful in
smaller portions of Apex. For example,
• declaring a method as global in an anonymous block
does not enable you to call it from outside of that
code.
private
• This is the default, and means that the method or
SALESFORCE variable is accessible only within the Apex class in
which it is defined. If you do not specify an access
CRM modifier, the method or variable is private.

• protected
• This means that the method or variable is visible to
any inner classes in the defining Apex class, and to
the classes that extend the defining Apex class. You
can only use this access modifier for instance
methods and member variables. Note that it is
strictly more permissive than the default (private)
setting, just like Java.
• public
• This means the method or variable can be

used byany Apex in this application or namespace.


SALESFORCE
CRM • global
• This means the method or variable can be used by
any Apex code that has access to the class, not just
the Apex code in the same application. This access
modifier should be used for any method that needs
to be referenced outside of the application, either in
the SOAP API or by other Apex code.
• If you declare a method or variable as global, you
must also declare the class that contains it as global.
• Static and Instance Methods, Variables, and
Initialization Code
• In Apex, you can have static methods, variables, and
SALESFORCE initialization code. However, Apex classes can’t be
CRM static. You can also have instance methods, member
variables, and initialization code, which have no
modifier, and local variables.
• Characteristics
• Static methods, variables, and initialization code
have these characteristics.

• They’re associated with a class.


• They’re allowed only in outer classes.
• They’re initialized only when a class is loaded.
• They aren’t transmitted as part of the view state
for a Visualforce page.
• Instance methods, member variables, and
SALESFORCE initialization code have these characteristics.
CRM
• They’re associated with a particular object.
• They have no definition modifier.
• They’re created with every object instantiated from
the class in which they’re declared.
• Local variables have these characteristics.

• They’re associated with the block of code in which


they’re declared.
• They must be initialized before they’re used.
• 1. Both action support and action function can be
used to call a controller method using an AJAX
request.

SALESFORCE • * for example call controller onclick of a inputcheck


CRM box
• * or call a controller method onfocus of a input
field
• Well, they both do the same thing of calling
controller method.
Difference between both:

SALESFORCE • 1. Action function can call the controller method from


CRM java script.
• • 2. Action support adds AJAX support to another
visualforce component and then call the controller
method.
• for example:

• <apex:outputpanel id="outptpnl">
• <apex:outputText value="click here"/>
• <apex:actionSupport event="onclick"
action="{!controllerMethodName}" rerender="pgblck"
/>
• Here action support adds AJAX to output panel,
so once you click on output panel controller method
SALESFORCE willbe called.
CRM •
• 3. Action function cannot add AJAX support to
another component. But from a particular
component which has AJAX support(onclick, onblur
etc) action function can be called to call the controller
method.
• Example:
• <apex:actionFunction name="myactionfun"
action="{!actionFunMethod}" reRender="outptText"/>
SALESFORCE <apex:inputcheckbox onclick="myJavaMethod()" />
CRM <script>
function myJavaMethod(){
myactionfun();// this call the action function

}
</script>
• <apex:actionFunction name="myactionfun"
action="{!actionFunMethod}" reRender="outptText"/>
SALESFORCE <apex:inputcheckbox onclick="myJavaMethod()" />
CRM <script>
function myJavaMethod(){
myactionfun();// this call the action function

}
</script>

Reference :
https://www.cloudforce4u.com/2013/06/difference-be
tween-action-support-and.html
Deployment Tools :
Different Deployment Methods
1. Change Sets
SALESFORCE
2. Eclipse with Force.com IDE
CRM
3. Force.com Migration Tool – ANT/Java based

Change Sets
The easiest way to send configuration changes from
one Salesforce organization to another is to use a
change set though it has a limitation that we can use it
among connected Salesforce orgs only (like Developer
Sandbox to Test Sandbox & Test Sandbox to
Production Org etc). We cannot use it in between any
individual Salesforce orgs.
To use change sets we need to have two
Salesforce org’s i.e. one Production org and its Sandbox org.

SALESFORCE
CRM Production Org:
It is Salesforce org with live data which is being actively used.

Sandbox:
A sandbox is a copy of your production organization. Sandboxes
contain the same metadata as production organization.

Outbound Change Sets:


Make changes in the organization you are logged into, and upload
those changes to another organization.
Inbound Change Sets:
Accept, modify, or reject change sets uploaded from other
SALESFORCE organizations.
CRM Change sets require a deployment connection between the two
Salesforce organizations.
The first step is to create this connection. To create a connection,
follow the below steps:
Steps to create Deployment Connections

SALESFORCE Create one or more sandboxes.


CRM Go to Setup >> App Setup >> Deploy >> Deployment Connections /
Deployment Settings. It will show you information on Change set
and Outbound/Inbound change set information. Press ‘Continue’
button on this page.
Click ‘Name’ to view existing connection details. We can see this
record only if Sandbox is created for Production Org.
Click ‘Edit’ to authorize inbound changes from a listed
organization.
For ANT tool migration .

http://www.infallibletechie.com/2014/07/salesforce-components-
names-for-ant-tool.html
SALESFORCE
CRM
Test Class :
At least 75% of your Apex code must be covered by unit tests, and
all of those tests must complete successfully. But this should not
be our focus. We should aim for 100% code coverage, which
SALESFORCE ensures that you cover each positive and negative use case of your
code to cover and test each and every branch of your code.
CRM
Calls to System.debug are not counted as part of Apex code
coverage.
Test methods and test classes are not counted as part of Apex
code limit. So, no worries about writing long test class with more
methods just to make sure that all your code branches are
covered.
Every trigger you are trying to deploy should have at least 1%
coverage, but yes overall coverage of your production org after
getting your code deployed should be 75%, otherwise Salesforce
won’t let you deploy your code.
SALESFORCE
CRM Class can be deployed on 0% coverage as well, but as I told in last
point, that overall coverage of your production org after getting
your code deployed should be 75%, otherwise Salesforce won’t let
you deploy your code.
Class can be deployed on 0% coverage as well, but as I told in last
point, that overall coverage of your production org after getting
your code deployed should be 75%, otherwise Salesforce won’t let
you deploy your code.

SALESFORCE
CRM The key points while writing a test class are:
You have to start your class with @isTest annotation, then only
Salesforce will consider this class as test class.
Keep your class as Private, and the best practice is to name your
test class as your original Class or trigger Name + ‘Test’.
Methods of your test class have to be static, void and testMethod
keyword has to be used.
Prepare your test data which needs to be existing before your
actual test runs. There are multiple techniques of creating test data
now a days, for example, setup method, static resources etc. For
more details about @testsetup method check below link
@testSetup method in apex test class
Use Test.startTest() and Test.stopTest() to make sure that the actual
testing of your code happens with the fresh set of governer limits.
These methods help you to reset your governor limits just before
your actual code of testing get executed.

SALESFORCE Once your test code runs between Test.startTest() and


Test.stopTest(), you must use assert statements to test whether
CRM your actual code is executing correctly and giving the results as
expected. In our case, we are test whether book’s price has been
set to 90 or not. If this assert statement returns false, then your
test class will fail, and will let you know, that something is not
correct in your code, and you need to fix your original code.
Because we are testing a simple trigger, we could not show the
testing using negative use cases, but in an ideal world, you should
write multiple methods in your test class, few should test your
positive use cases, and other should test your negative test cases.
Adding Remote Site Settings
Before any Apex callout can call an external site, that site
SALESFORCE must be registered in the Remote Site Settings page, or
CRM the callout fails. Salesforce prevents calls to unauthorized
Named Credentials :
HttpRequest req = new HttpRequest();

SALESFORCE req.setEndpoint('callout:My_Named_Credential/some_p
CRM ath');
Code Without Named Credentials :
HttpRequest req = new HttpRequest();
req.setEndpoint('https://my_endpoint.example.com/so
SALESFORCE me_path');
CRM
// - The header and header information
String username = 'myname';
String password = 'mypwd';
SALESFORCE Blob headerValue = Blob.valueOf(username + ':' + password);

CRM
Salesforce Integration
Make Callouts to External Services from Apex
• An Apex callout enables you to tightly integrate your Apex code
with an external service. The callout makes a call to an external
SALESFORCE web service or sends an HTTP request from Apex code, and then
CRM receives the response.
• Apex callouts come in two flavors.
• Web service callouts to SOAP web services use XML, and
typically require a WSDL document for code generation.
• HTTP callouts to services typically use REST with JSON.
• These two types of callouts are similar in terms of sending a
request to a service and receiving a response. But while
WSDL-based callouts apply to SOAP Web services, HTTP
callouts can be used with any HTTP service, either SOAP or
REST.
Salesforce Integration
Rest Vs Soap
The following are the differences between SOAP and REST API:
1.REST API has no has no official standard at all because it is an
SALESFORCE architectural style. SOAP API, on the other hand,has an official
CRM standard because it is a protocol.
2. REST APIs uses multiple standards like HTTP, JSON, URL, and
XML while SOAP APIs is largely based on HTTP and XML.
3. As REST API deploys multiple standards, so it takes fewer
resources and bandwidth as compared to SOAP that uses XML for
the creation of Payload and results in the large sized file.
4. The ways both APIs exposes the business logics are
also different. REST API takes advantage of URL
exposure like @path("/WeatherService") while SOAP API
use of services interfaces like @WebService.
Salesforce Integration
Rest Vs Soap
5. SOAP API defines too many standards, and its implementer
implements the things in a standard way only. In the case of
SALESFORCE miscommunication from service, the result will be the error. REST
CRM API, on the other hand, don't make emphasis on too many
standards and results in corrupt API in the end.
6. REST API uses Web Application Description Language, and
SOAP API used Web Services Description language for describing
the functionalities being offered by web services.
7.REST APIs are more convenient with JavaScript and can be
implemented easily as well. SOAP APIs are also convenient with
JavaScript but don't support for greater implementation.
Workbench API:
/services/data/v45.0/sobjects/account

SALESFORCE Request Body :


CRM
{
"Name" : "NewAccount1",
"ShippingCity" : "San Francisco"

}
REST “GET”
Http http = new Http();
HttpRequest request = new HttpRequest();

SALESFORCE request.setEndpoint('https://th-apex-http-callout.herokuapp.com/
CRM animals');
request.setMethod('GET');
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if (response.getStatusCode() == 200) {
// Deserialize the JSON string into collections of primitive data
types.
Map<String, Object> results = (Map<String, Object>)
JSON.deserializeUntyped(response.getBody());
// Cast the values in the 'animals' key as a list
List<Object> animals = (List<Object>)
SALESFORCE results.get('animals');
CRM System.debug('Received the following
animals:');
for (Object animal: animals) {
System.debug(animal);

}
}
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://th-apex-http-callo
SALESFORCE ut.herokuapp.com/animals');
CRM
request.setMethod('POST');
request.setHeader('Content-Type',
'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody('{"name":"mighty moose"}');
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() != 201) {
SALESFORCE System.debug('The status code returned was
CRM not expected: ' +
response.getStatusCode() + ' ' +
response.getStatus());
} else {
System.debug(response.getBody());

}
Salesforce provides a WSDL (Web Service
Description Language) files. They are called
“Enterprise WSDL” and “Partner WSDL”. The
SALESFORCE WSDL is used by developers to aid in the
CRM creation of Salesforce integration pieces. A
typical process involves using the
Development Environment (eg, Eclipse for
Java, or Visual Studio for .Net) to consume the
WSDL, and generate classes which are then
referenced in the integration.
Enterprise WSDL:

The Enterprise WSDL is strongly typed, which


SALESFORCE means that it contains objects and fields with
CRM specific data types, such as int and string.
The Enterprise WSDL document is for
customers who want to build an integration
with their Salesforce organization only.
Customers who use the enterprise WSDL
document must download and re-consume it
whenever their organization makes a change to
its custom objects or fields or whenever they
Partner WSDL:

The Partner WSDL is loosely typed, which


SALESFORCE means that you work with name-value pairs of
CRM field names and values instead of specific data
types.
This WSDL document is for customers,
partners, and ISVs who want to build an
integration that can work across multiple
Salesforce organizations, regardless of their
custom objects or fields.
The Partner WSDL is static, and hence does not
SOAP Best Working Scenarios :
https://developer.salesforce.com/blogs/develo
per-relations/2015/06/salesforce-soap-api-sa
SALESFORCE mple-wsdls.html
CRM
Salesforce Integration
Rest

SALESFORCE
CRM HTTP Method Description

GET Retrieve data identified by a URL.

POST Create a resource or post data to the


server.
DELETE Delete a resource identified by a URL.

PUT Create or replace the resource sent in


the request body.
Lightning Enablement :
Visualforce page is not equivalent to Lightning Component. Hence it i
not necessary to have a equivalent tag corresponding to a Visualforce
SALESFORCE tag in Lightning Component. Binding works the same as in Visualforce
CRM page except for the fact that your variable will be an <aura:attribute>
and these are filled in the Controller.js.

In order to convert a Visualforce Page to Lightning, you need first start


thinking in terms of components or breaking down your big page in to
small re-usable components. Then we build these small components
and finally tie them all up to create the app or the equivalent VF page
you had.

For your example, you need to look into lightning:recordEditForm and


lightning:inputField.

One of the best ways to learn all the tags is by looking at the
Component
Convert VF page to lightning :
lightningStyleSheets="true"

SALESFORCE
CRM <apex:stylesheet
value="{!URLFOR($Resource.SLDS213,

'assets/styles/salesforce-lightning-design-system-
vf.css')}" />
<div class="slds myns">
<!-- the rest of your VF code goes here -->
</div>
Usage of Salesforce Optimizer:

Salesforce Optimizer analyzes your


SALESFORCE implementation to determine ways that you can
CRM simplify customizations and drive adoption of
features.
THANK YOU

You might also like