Download as pdf or txt
Download as pdf or txt
You are on page 1of 111

Trailhead Virtual Bootcamp for Platform Developer I

Trailhead Virtual Bootcamp for


Platform Developer I
Welcome Session

Copyright

© Copyright 2000-2020 salesforce.com, inc. All rights reserved. Various trademarks


held by their respective owners.

Rights of ALBERT EINSTEIN are used with permission of The Hebrew University of
Jerusalem. Represented exclusively by Greenlight.

This document contains proprietary information of salesforce.com, inc., it is provided


under a license agreement containing restrictions on use, duplication and disclosure
and is also protected by copyright law. Permission is granted to customers of
salesforce.com, inc. to use and modify this document for their internal business
purposes only. Resale of this document or its contents is prohibited.

The information in this document is subject to change without notice. Should you find
any problems or errors, please log a case from the Support link on the Salesforce home
page. Salesforce.com, inc. does not warrant that this document is error-free.

© Copyright 2020 salesforce.com, inc. 1


Trailhead Virtual Bootcamp for Platform Developer I

Forward Looking Statements 3

"Safe harbor" statement under the Private Securities Litigation Reform Act of 1995: This presentation contains forward-looking statements about the company's financial and
operating results, which may include expected GAAP and non-GAAP financial and other operating and non-operating results, including revenue, net income, diluted earnings
per share, operating cash flow growth, operating margin improvement, expected revenue growth, expected current remaining performance obligation growth, expected tax rates,
stock-based compensation expenses, amortization of purchased intangibles, shares outstanding, market growth, environmental, social and governance goals and expected capital
allocation, including mergers and acquisitions, capital expenditures and other investments. The achievement or success of the matters covered by such forward-looking
statements involves risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any of the assumptions prove incorrect, the company’s results could
differ materially from the results expressed or implied by the forward-looking statements it makes.
The risks and uncertainties referred to above include -- but are not limited to -- risks associated with the effect of general economic and market conditions; the impact of
geopolitical events, natural disasters and actual or threatened public health emergencies, such as the ongoing Coronavirus pandemic; the impact of foreign currency exchange
rate and interest rate fluctuations on our results; our business strategy and our plan to build our business, including our strategy to be the leading provider of enterprise cloud
computing applications and platforms; the pace of change and innovation in enterprise cloud computing services; the seasonal nature of our sales cycles; the competitive nature
of the market in which we participate; our international expansion strategy; the demands on our personnel and infrastructure resulting from significant growth in our customer
base and operations, including as a result of acquisitions; our service performance and security, including the resources and costs required to avoid unanticipated downtime and
prevent, detect and remediate potential security breaches; the expenses associated with our data centers and third-party infrastructure providers; additional data center capacity;
real estate and office facilities space; our operating results and cash flows; new services and product features, including any efforts to expand our services beyond the CRM market;
our strategy of acquiring or making investments in complementary businesses, joint ventures, services, technologies and intellectual property rights; the performance and fair
value of our investments in complementary businesses through our strategic investment portfolio; our ability to realize the benefits from strategic partnerships, joint ventures and
investments; the impact of future gains or losses from our strategic investment portfolio, including gains or losses from overall market conditions that may affect the publicly
traded companies within our strategic investment portfolio; our ability to execute our business plans; our ability to successfully integrate acquired businesses and technologies; our
ability to continue to grow unearned revenue and remaining performance obligation; our ability to protect our intellectual property rights; our ability to develop our brands; our
reliance on third-party hardware, software and platform providers; our dependency on the development and maintenance of the infrastructure of the Internet; the effect of
evolving domestic and foreign government regulations, including those related to the provision of services on the Internet, those related to accessing the Internet, and those
addressing data privacy, cross-border data transfers and import and export controls; the valuation of our deferred tax assets and the release of related valuation allowances; the
potential availability of additional tax assets in the future; the impact of new accounting pronouncements and tax laws; uncertainties affecting our ability to estimate our tax rate;
uncertainties regarding our tax obligations in connection with potential jurisdictional transfers of intellectual property, including the tax rate, the timing of the transfer and the
value of such transferred intellectual property; the impact of expensing stock options and other equity awards; the sufficiency of our capital resources; factors related to our
outstanding debt, revolving credit facility and loan associated with 50 Fremont; compliance with our debt covenants and lease obligations; current and potential litigation involving
us; and the impact of climate change.
Further information on these and other factors that could affect the company’s financial results is included in the reports on Forms 10-K, 10-Q and 8-K and in other filings it makes
with the Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of the company’s
website at.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements, except as required by law.

Virtual Bootcamp Goals 4

LEARN FROM THE SOURCE

© Copyright 2020 salesforce.com, inc. 2


Trailhead Virtual Bootcamp for Platform Developer I

About This Course 5

This is a Platform Developer I certification


preparation course designed for programmatic
developers who are new to the Salesforce
platform and need to be able to make
programmatic customizations using Apex.

The course also covers declarative customizations


and an introduction to Lightning Web
Components, Aura Components, and Visualforce.

About the Platform Developer I Exam 6

• 60 multiple-choice/multiple-select questions.

• 110 minutes to complete the exam.

• 65% is the passing score.


• Normal registration fee is $200 US and the retake fee
is $100 US.

• Delivery options are proctored exam delivered onsite


at a testing center or in an online proctored
environment.

• No hard-copy or online materials may be referenced


during the exam.
© Copyright 2020 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.

© Copyright 2020 salesforce.com, inc. 3


Trailhead Virtual Bootcamp for Platform Developer I

Exam Objectives: A Visual Representation 7

User Interface 25% Testing,


Debugging, and
Deployment
17%
Salesforce
Fundamentals
7%
Process Data
Automation and Modeling and
Logic 38% Management
13%

Weekly Schedule 88

• Self-paced assignments every Monday,


Tuesday, Wednesday, and Thursday

• 30-minute Instructor Q & A session every


Wednesday

• 90-minute Instructor Review session every


Friday

NOTE:
This welcome session is the only instructor session we’ll have on a Monday.

© Copyright 2020 salesforce.com, inc. 4


Trailhead Virtual Bootcamp for Platform Developer I

Log Into Bootcamp Org 9

Virtual Bootcamp Login

URL: login.salesforce.com

Username:(provided
through welcome email)
Password:(set by you
during your first login)

Getting Started 10

In the Bootcamp org, make


sure you’re on the Virtual
Bootcamp Tab.

Before deep diving into


Developer topics, be sure
you’re familiar with the Exam
Guide and Trailhead Basics.

© Copyright 2020 salesforce.com, inc. 5


Trailhead Virtual Bootcamp for Platform Developer I

Daily Assignments 11

Click the Week 1 link to


view daily assignments.

Do NOT use your Bootcamp


Org username to log into
Trailhead. Trailhead login is
discussed on the next slide….

Trailhead Login 12
12

Trailhead Login
• URL: https://trailhead.salesforce.com
• Do NOT use your Virtual Bootcamp Org username to log into Trailhead
• Use existing Trailhead or work login or create Developer org (see below)

Developer Org The picture can't be displayed.

• Signup URL: https://developer.salesforce.com/signup


• Login URL: http://login.salesforce.com
• Username: Setup by You (we recommend firstname.lastname@trailhead.com)
• Password: Set by You
• Now use this new org to Log into Trailhead

© Copyright 2020 salesforce.com, inc. 6


Trailhead Virtual Bootcamp for Platform Developer I

Access Instructor Sessions and Slides 13

View slides
presented by
instructor

Access Webex for


each session, then
access recording
about 24 hours
after each session

Support and Resources 14

Search for info on


common questions
and issues on the
Knowledge tab.

Can't find the answer you


need? Log a Case on the
Virtual Bootcamp tab.

© Copyright 2020 salesforce.com, inc. 7


Trailhead Virtual Bootcamp for Platform Developer I

Trailhead Virtual Bootcamp for Platform Developer I

Welcome Session
Q&A

Week 1: Where you’re going 16


16

• Salesforce Platform Basics Module • Formulas & Validations Module


– Get Started with the Salesforce Platform – Use Formula Fields
– Discover Use Cases for the Platform – Implement Roll-Up Summary Fields
– Understand the Salesforce Architecture – Create Validation Rules
– Navigate Setup
– Power Up with AppExchange • Salesforce Help Pages
– Create a Workflow Rule
• Data Modeling Module
– Understand Custom & Standard Objects
– Create Object Relationships
– Work with Schema Builder

© Copyright 2020 salesforce.com, inc. 8


Trailhead Virtual Bootcamp for Platform Developer I

We are here to
help you on
your learning
journey....

© Copyright 2020 salesforce.com, inc. All rights reserved. Various trademarks held by their respective owners.

Trailhead Virtual Bootcamp for


Platform Developer I
Week 1 Q&A

© Copyright 2020 salesforce.com, inc. 9


Trailhead Virtual Bootcamp for Platform Developer I

Trailhead Virtual Bootcamp for


Platform Developer I
Instructor Session:
Week 1 Review

Copyright

© Copyright 2000-2020 salesforce.com, inc. All rights reserved. Various trademarks


held by their respective owners.

Rights of ALBERT EINSTEIN are used with permission of The Hebrew University of
Jerusalem. Represented exclusively by Greenlight.

This document contains proprietary information of salesforce.com, inc., it is provided


under a license agreement containing restrictions on use, duplication and disclosure
and is also protected by copyright law. Permission is granted to customers of
salesforce.com, inc. to use and modify this document for their internal business
purposes only. Resale of this document or its contents is prohibited.

The information in this document is subject to change without notice. Should you find
any problems or errors, please log a case from the Support link on the Salesforce home
page. Salesforce.com, inc. does not warrant that this document is error-free.

20

© Copyright 2020 salesforce.com, inc. 10


Trailhead Virtual Bootcamp for Platform Developer I

Forward Looking Statements 21

"Safe harbor" statement under the Private Securities Litigation Reform Act of 1995: This presentation contains forward-looking statements about the company's financial and
operating results, which may include expected GAAP and non-GAAP financial and other operating and non-operating results, including revenue, net income, diluted earnings
per share, operating cash flow growth, operating margin improvement, expected revenue growth, expected current remaining performance obligation growth, expected tax rates,
stock-based compensation expenses, amortization of purchased intangibles, shares outstanding, market growth, environmental, social and governance goals and expected capital
allocation, including mergers and acquisitions, capital expenditures and other investments. The achievement or success of the matters covered by such forward-looking
statements involves risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any of the assumptions prove incorrect, the company’s results could
differ materially from the results expressed or implied by the forward-looking statements it makes.
The risks and uncertainties referred to above include -- but are not limited to -- risks associated with the effect of general economic and market conditions; the impact of
geopolitical events, natural disasters and actual or threatened public health emergencies, such as the ongoing Coronavirus pandemic; the impact of foreign currency exchange
rate and interest rate fluctuations on our results; our business strategy and our plan to build our business, including our strategy to be the leading provider of enterprise cloud
computing applications and platforms; the pace of change and innovation in enterprise cloud computing services; the seasonal nature of our sales cycles; the competitive nature
of the market in which we participate; our international expansion strategy; the demands on our personnel and infrastructure resulting from significant growth in our customer
base and operations, including as a result of acquisitions; our service performance and security, including the resources and costs required to avoid unanticipated downtime and
prevent, detect and remediate potential security breaches; the expenses associated with our data centers and third-party infrastructure providers; additional data center capacity;
real estate and office facilities space; our operating results and cash flows; new services and product features, including any efforts to expand our services beyond the CRM market;
our strategy of acquiring or making investments in complementary businesses, joint ventures, services, technologies and intellectual property rights; the performance and fair
value of our investments in complementary businesses through our strategic investment portfolio; our ability to realize the benefits from strategic partnerships, joint ventures and
investments; the impact of future gains or losses from our strategic investment portfolio, including gains or losses from overall market conditions that may affect the publicly
traded companies within our strategic investment portfolio; our ability to execute our business plans; our ability to successfully integrate acquired businesses and technologies; our
ability to continue to grow unearned revenue and remaining performance obligation; our ability to protect our intellectual property rights; our ability to develop our brands; our
reliance on third-party hardware, software and platform providers; our dependency on the development and maintenance of the infrastructure of the Internet; the effect of
evolving domestic and foreign government regulations, including those related to the provision of services on the Internet, those related to accessing the Internet, and those
addressing data privacy, cross-border data transfers and import and export controls; the valuation of our deferred tax assets and the release of related valuation allowances; the
potential availability of additional tax assets in the future; the impact of new accounting pronouncements and tax laws; uncertainties affecting our ability to estimate our tax rate;
uncertainties regarding our tax obligations in connection with potential jurisdictional transfers of intellectual property, including the tax rate, the timing of the transfer and the
value of such transferred intellectual property; the impact of expensing stock options and other equity awards; the sufficiency of our capital resources; factors related to our
outstanding debt, revolving credit facility and loan associated with 50 Fremont; compliance with our debt covenants and lease obligations; current and potential litigation involving
us; and the impact of climate change.
Further information on these and other factors that could affect the company’s financial results is included in the reports on Forms 10-K, 10-Q and 8-K and in other filings it makes
with the Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of the company’s
website at.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements, except as required by law.

Lesson Agenda 22

• Salesforce Platform Architecture


• Customization Options
• Objects, Fields, and Relationships
• Formula and Roll-Up Summary Fields

© Copyright 2020 salesforce.com, inc. 11


Trailhead Virtual Bootcamp for Platform Developer I

23
Salesforce Architecture

Multi-Tenant Cloud 24

DEFINITION: Multi-tenancy means that a single instance of the software, database, and
supporting infrastructure serves multiple customers, while each tenant's data is isolated and
remains invisible to other tenants.

Your
dedicated
space
Shared
resources for
power, water,
and building
maintenance

© Copyright 2020 salesforce.com, inc. 12


Trailhead Virtual Bootcamp for Platform Developer I

Considerations of Multi-tenancy 25

Resources shared by Salesforce tenants include:

• The database, including data, metadata, indexes, field


histories, and data relationships.
§ An org has a unique identifier that helps Salesforce identify
which data belongs to that org.

• The runtime engine.


§ To ensure that each tenant can access the runtime engine's
resources, each tenant is allocated a certain amount of
resources. Exceeding these allocations causes exceptions.
RESOURCE:

NOTE:
In multi-tenant environments the IT resources are shared cost-efficiently and securely.

Lesson Agenda 26

• Salesforce Platform Architecture


• Customization Options
• Objects, Fields, and Relationships
• Formula and Roll-Up Summary Fields

© Copyright 2020 salesforce.com, inc. 13


Trailhead Virtual Bootcamp for Platform Developer I

Declarative vs. Programmatic Customizations 27

Apps Tabs
Page Layouts User Lightning Components
Lightning Apps Interface Visualforce
Quick Actions

Validation Rules
Processes / Flows Business Apex
Workflow Rules Logic
Approval Processes

Objects
Fields Data APIs
Model
Relationships

Declarative Programmatic

Choosing Among Customization Options 28

Configure Buy Build


Standard and custom solutions from Download apps and components from Develop new solutions using
the Setup menu the AppExchange programmatic tools

Declarative Package Programmatic


(Point & Click) (Installed) (Code)
§ No programming experience § Proven and reviewed § Create apps that can do
required. solutions built for Salesforce. almost anything you want.
§ Integrated; updates
automatically with § May include support and § Custom code builds on point
Salesforce releases. maintenance. and click functionality.
Simplicity & Speed Already Built Control & Flexibility
Salesforce Platform

© Copyright 2020 salesforce.com, inc. 14


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 29

• Salesforce Platform Architecture


• Customization Options
• Objects, Fields, and Relationships
• Formula and Roll-Up Summary Fields

What is an Object on the Salesforce Platform? 30

USER INTERFACE

Analogous to
database tables Contacts Tab
OBJECTS

CONTACT

Page Layout

Relationship

FAVORITE
Favorites
Related List

© Copyright 2020 salesforce.com, inc. 15


Trailhead Virtual Bootcamp for Platform Developer I

Types of Objects on the Lightning Platform 31

Standard Objects are provided out of


the box.

Custom Objects are created by you to


extend the data model.

System Objects provide data for the


Salesforce platform operations.
Jessica Heinz
SW Dev. Manager

NOTE:
Both Standard and Custom objects contain data for use by your users.

What is a Standard Object? 32

Account: Each standard object comes with a predefined


A company with which you set of standard fields.
do business

DEFINITION:
A standard object is an object that is predefined by Salesforce.

© Copyright 2020 salesforce.com, inc. 16


Trailhead Virtual Bootcamp for Platform Developer I

Salesforce Data Model 33

Campaign Account
The “Sales Objects”
Data Model illustrates
that there are core
schema components:
• Standard objects Contact
• Standard relationships
between those objects

Opportunity

Lead Case

What is a Custom Object? 34

DEFINITION:
A custom object is created by a developer to capture and manage additional data based on
DEFINITION:

specific business requirements.

© Copyright 2020 salesforce.com, inc. 17


Trailhead Virtual Bootcamp for Platform Developer I

Schema Builder 35

A graphical tool that lets you use drag-and-drop to view, create,


and modify custom:
• Objects.
• Fields.
• Relationships.

NOTE: Schema Builder provides a quick graphical way to manipulate the data model, but it does
not support all features available in Object Manager.

Field Types 36

123 ABC Ω
Numeric Field Limited Option Text Data Types Calculation Data Types
Data Types Data Types • Text • Auto-Number
• Number • Checkbox • Text Area – Select the display format
• Currency • Picklist • Text Area (Long) – Increment by 1
• Percent • Picklist • Text Area (Rich)
(Multi-Select) • Encrypted • Formula
– Perform calculations on
a record
– Can span across objects
ABC
• Roll-Up Summary
Formatted Text Calendar Data Types Other – Created on a master
Data Types • Date • Geolocation – Allow calculations on
• Email • Date/Time details
• Phone • Time
• URL

© Copyright 2020 salesforce.com, inc. 18


Trailhead Virtual Bootcamp for Platform Developer I

Field Labels vs. API Names 37

Name displayed in the user


interface. Field label and field name
can be specified during field
creation.

Used to automatically generate the


API name by appending "__c".

Automatically generated by
Name used in code and by the API. the system based on field
name when the definition
is saved.

Other Field Attributes 38

Description (administrative
purposes).

Text displayed when users


hover over the Info icon. Require a value in order to save record.

Enforce uniqueness across records.

Indicates that the field is a key from an


external system (indexed).

Value used to pre-populate field data.

NOTE:
The field attributes vary depending on the field type.

© Copyright 2020 salesforce.com, inc. 19


Trailhead Virtual Bootcamp for Platform Developer I

Relating Objects: A Lookup Relationship 39

§ The child record and parent record have independent sharing.


Contact Customer Story

§ The lookup field on the child record can be optional or required.

This option only available


§ You can add a lookup filter. if enabled by Support

Relating Objects: a Master-Detail Relationship 40

§ Sharing for the detail record is § The parent reference is always


inherited from the master record. required on the child record.
Account Customer Story

§ You can add a lookup filter.


§ You can choose whether or not the
detail record can be reparented.
§ The detail record is automatically
deleted when the parent is deleted.

NOTE:
NOTE:

The detail side of a custom master-detail relationship must be a custom object.

© Copyright 2020 salesforce.com, inc. 20


Trailhead Virtual Bootcamp for Platform Developer I

Lookup vs. Master-Detail 41

Lookup Master-Detail
Relationships Relationships
Parent field on child is required. ü
Access to parent determines access
ü
to children.
Deleting the parent always
ü
automatically deletes children.
Lookup field on page layout depends
ü
on required/optional choice.

Lesson Agenda 42

• Salesforce Platform Architecture


• Customization Options
• Objects, Fields, and Relationships
• Formula and Roll-Up Summary Fields

© Copyright 2020 salesforce.com, inc. 21


Trailhead Virtual Bootcamp for Platform Developer I

Working with a Formula Field 43

A formula can return


DEFINITION: onefield
A formula of these data
is a field thattypes:
derivesCheckbox,
its value fromCurrency,
other fields,Date,
expressions, or
Date/Time, Number,
values. You can createPercent, Text.formula on a child object to reference data from parent
a cross-object
objects, up to 10 relationships away.

Course Delivery

NOTE:
A formula field is calculated each time a user views a record or report.

What is a Roll-Up Summary Field? 44

DEFINITION: A roll-up summary field is a field on a master record that summarizes date or
numerical data from detail records.

Select the detail object


to summarize.

Set the roll-up type to


count, sum, min, or max.

Determine which records to


include in the calculation.

NOTE:
A roll-up summary field is recalculated whenever any referenced detail record is saved.

© Copyright 2020 salesforce.com, inc. 22


Trailhead Virtual Bootcamp for Platform Developer I

Week 1 Knowledge Check 45


45

1. How can a developer customize an object on the Salesforce Platform?

2. How can a developer reference a field programmatically?

3. What is a consideration for creating a master-detail relationship


between two objects?

4. What is a consideration for creating a lookup relationship between two


objects?

5. What is a capability of formula fields?

REVIEW SESSION
WEEK 1

Q & A

© Copyright 2020 salesforce.com, inc. 23


Trailhead Virtual Bootcamp for Platform Developer I

Week 1: Where you’ve been 47


47

• Salesforce Platform Basics Module • Formulas & Validations Module


– Get Started with the Salesforce Platform – Use Formula Fields
– Discover Use Cases for the Platform – Implement Roll-Up Summary Fields
– Understand the Salesforce Architecture – Create Validation Rules
– Navigate Setup
– Power Up with AppExchange • Salesforce Help Pages
– Create a Workflow Rule
• Data Modeling Module
– Understand Custom & Standard Objects
– Create Object Relationships
– Work with Schema Builder

Week 2: Where you’re going 48


48

• Lightning Flow Module • Salesforce Help Pages


– Choose the Right Automation Tool – Which Automation Tool Do I Use?
– Automate Simple Business Processes
with Process Builder
• Apex Basics & Database Module
– Guide Users Through Your Business
– Get Started with Apex
Processes with Flow Builder
– Use sObjects
– Combine the Power of Process Builder
and Flow Builder
– Customize How Records Get Approved • Apex Basics for Admins Module
with Approvals – Control Data Flow
– Use Loops
• Platform Development Basics Module
– Get Started with the Salesforce Platform
– Develop Without Code
– Code with Salesforce Languages
– Extend the Salesforce Platform

© Copyright 2020 salesforce.com, inc. 24


Trailhead Virtual Bootcamp for Platform Developer I

Trailhead Virtual Bootcamp for


Platform Developer I
Week 2 Q&A

Trailhead Virtual Bootcamp for


Platform Developer I
Instructor Session:
Week 2 Review

© Copyright 2020 salesforce.com, inc. 25


Trailhead Virtual Bootcamp for Platform Developer I

Copyright

© Copyright 2000-2020 salesforce.com, inc. All rights reserved. Various trademarks


held by their respective owners.

Rights of ALBERT EINSTEIN are used with permission of The Hebrew University of
Jerusalem. Represented exclusively by Greenlight.

This document contains proprietary information of salesforce.com, inc., it is provided


under a license agreement containing restrictions on use, duplication and disclosure
and is also protected by copyright law. Permission is granted to customers of
salesforce.com, inc. to use and modify this document for their internal business
purposes only. Resale of this document or its contents is prohibited.

The information in this document is subject to change without notice. Should you find
any problems or errors, please log a case from the Support link on the Salesforce home
page. Salesforce.com, inc. does not warrant that this document is error-free.

51

Forward Looking Statements 52

"Safe harbor" statement under the Private Securities Litigation Reform Act of 1995: This presentation contains forward-looking statements about the company's financial and
operating results, which may include expected GAAP and non-GAAP financial and other operating and non-operating results, including revenue, net income, diluted earnings
per share, operating cash flow growth, operating margin improvement, expected revenue growth, expected current remaining performance obligation growth, expected tax rates,
stock-based compensation expenses, amortization of purchased intangibles, shares outstanding, market growth, environmental, social and governance goals and expected capital
allocation, including mergers and acquisitions, capital expenditures and other investments. The achievement or success of the matters covered by such forward-looking
statements involves risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any of the assumptions prove incorrect, the company’s results could
differ materially from the results expressed or implied by the forward-looking statements it makes.
The risks and uncertainties referred to above include -- but are not limited to -- risks associated with the effect of general economic and market conditions; the impact of
geopolitical events, natural disasters and actual or threatened public health emergencies, such as the ongoing Coronavirus pandemic; the impact of foreign currency exchange
rate and interest rate fluctuations on our results; our business strategy and our plan to build our business, including our strategy to be the leading provider of enterprise cloud
computing applications and platforms; the pace of change and innovation in enterprise cloud computing services; the seasonal nature of our sales cycles; the competitive nature
of the market in which we participate; our international expansion strategy; the demands on our personnel and infrastructure resulting from significant growth in our customer
base and operations, including as a result of acquisitions; our service performance and security, including the resources and costs required to avoid unanticipated downtime and
prevent, detect and remediate potential security breaches; the expenses associated with our data centers and third-party infrastructure providers; additional data center capacity;
real estate and office facilities space; our operating results and cash flows; new services and product features, including any efforts to expand our services beyond the CRM market;
our strategy of acquiring or making investments in complementary businesses, joint ventures, services, technologies and intellectual property rights; the performance and fair
value of our investments in complementary businesses through our strategic investment portfolio; our ability to realize the benefits from strategic partnerships, joint ventures and
investments; the impact of future gains or losses from our strategic investment portfolio, including gains or losses from overall market conditions that may affect the publicly
traded companies within our strategic investment portfolio; our ability to execute our business plans; our ability to successfully integrate acquired businesses and technologies; our
ability to continue to grow unearned revenue and remaining performance obligation; our ability to protect our intellectual property rights; our ability to develop our brands; our
reliance on third-party hardware, software and platform providers; our dependency on the development and maintenance of the infrastructure of the Internet; the effect of
evolving domestic and foreign government regulations, including those related to the provision of services on the Internet, those related to accessing the Internet, and those
addressing data privacy, cross-border data transfers and import and export controls; the valuation of our deferred tax assets and the release of related valuation allowances; the
potential availability of additional tax assets in the future; the impact of new accounting pronouncements and tax laws; uncertainties affecting our ability to estimate our tax rate;
uncertainties regarding our tax obligations in connection with potential jurisdictional transfers of intellectual property, including the tax rate, the timing of the transfer and the
value of such transferred intellectual property; the impact of expensing stock options and other equity awards; the sufficiency of our capital resources; factors related to our
outstanding debt, revolving credit facility and loan associated with 50 Fremont; compliance with our debt covenants and lease obligations; current and potential litigation involving
us; and the impact of climate change.
Further information on these and other factors that could affect the company’s financial results is included in the reports on Forms 10-K, 10-Q and 8-K and in other filings it makes
with the Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of the company’s
website at.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements, except as required by law.

© Copyright 2020 salesforce.com, inc. 26


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 53

• Declarative Process Automation


• Apex Overview
• Data Types, Classes, and Methods
• Control Flow Statements
• sObjects

Automation Tools: Actions and Deployment 54

Tool Name Process Builder Flow Workflow Approval Process


Create record, Create, Update,
Update related Lookup, or Delete Task assigned, Record locked,
record, Post to Record(s); Email sent, Task assigned,
Chatter, Launch Submit for approval, Field update, Email sent,
List of Actions Flow,Quip, Email, Quip, Outbound API Field update,
Subprocess, Quick Action, message Outbound API
Submit for approval, Post to Chatter, message
Quick Action, Send Custom
Apex, Email, Send Notification
Custom Notification
Custom link,
Criteria are met and
Custom button, Criteria are met and Criteria are met and
one of the following: one of the following: one of the following:
Quick Action,
Invoked Via: Save button, Visualforce, Save button, Submit button ,
Dataloader, API, Process, Dataloader, Process, Flow,
DML: Insert/Update Lightning API, DML: Apex trigger
Component Insert/Update

© Copyright 2020 salesforce.com, inc. 27


Trailhead Virtual Bootcamp for Platform Developer I

Automation Tools: Other Features 55

Declarative Automation Tools

Process Builder Flow Workflow Approvals


(Y/N) (Y/N) (Y/N) (Y/N)
Supports time- Yes Yes Yes No
based actions
Supports user- No Yes No No
interaction
Can call Apex code Yes Yes No No

Can delete a No (only via Yes No No


record autolaunched flow)

Lesson Agenda 56

• Declarative Process Automation


• Apex Overview
• Data Types, Classes, and Methods
• Control Flow Statements
• sObjects

© Copyright 2020 salesforce.com, inc. 28


Trailhead Virtual Bootcamp for Platform Developer I

What is Apex? 57

DEFINITION: Apex is Salesforce’s cloud-based, object-oriented programming language,


specifically designed for customizing and extending apps on the Salesforce platform.
DEFINITION:

• Tailored for data access and manipulation.

• Works in conjunction with declarative features.

• Has access to your org's metadata.

• Designed to work effectively and efficiently in a multi-tenant


environment.

Apex Environment 58

DEFINITION:
Lightning Platform
Uncompiled
Apex Class or Compiled
Trigger Apex Apex
Compiler
Compiler Errors
Developer User Data
Application
Internet Server Storage
Request

Apex Compiled Apex


Result Apex
Runtime Class
End User

© Copyright 2020 salesforce.com, inc. 29


Trailhead Virtual Bootcamp for Platform Developer I

Developer Console and Anonymous Blocks 59

1 2 3

Lesson Agenda 60

• Declarative Process Automation


• Apex Overview
• Data Types, Classes, and Methods
• Control Flow Statements
• sObjects

© Copyright 2020 salesforce.com, inc. 30


Trailhead Virtual Bootcamp for Platform Developer I

Data Types: Primitives 61

Blob Decimal Long Regardless of type, Apex


Boolean Double String
initializes all variables to
the special value null.
Date ID Time
Datetime Integer Constants are declared
using the static +
1
2
//Sample String method
Boolean validString = userString.isAlphanumeric();
final modifiers.
3
4 //Sample Datetime method
5 Date curUserDate = curDateTime.date();
6
7 //Sample constant
8 static final DOUBLE PI = 3.14159;

NOTE: Although called primitives in Apex, these data types are similar to wrapper classes in Java.
Variables declared to be of these data types are all objects.

Collections 62

1A List<Account> accounts = new List<Account>();


2A accounts.add(new Account(name='Account 1')); An ordered (indexed) collection of
3A accounts.add(new Account(name='Account 2'));
elements which allows duplicates.
4A accounts.add(new Account(name='Account 1'));
5A System.debug('First account is ' + accounts.get(0));
6A System.debug('Second account is ' + accounts[1]);

1B Set<String> names = new Set<String>(); An unordered collection of elements


2B names.add('Acme');
3B names.add('Salesforce');
where duplicate values are ignored.
4B names.add('Salesforce');
5B System.debug('Does the set contain Pardot? ' + names.contains('Pardot'));
6B System.debug('The size of the set is: ' + names.size());

1C Map<String, Integer> counts= new Map<String,Integer>();


2C counts.put('Acme', 200); A collection of key / value pairs,
3C counts.put('Salesforce', 400);
4C counts.put('NewCorp', 200);
where each unique key maps to a
5C counts.put('Acme', 600); single (possible duplicate) value.
6C System.debug('The size of the map is: ‘+ counts.size());
7C System.debug('The count for Acme is '
+ (counts.containsKey('Acme') ? counts.get('Acme') : 0));

© Copyright 2020 salesforce.com, inc. 31


Trailhead Virtual Bootcamp for Platform Developer I

Defining an Apex Class 63

Access modifier: who can


see this class?

1 public class MyClass { A class can contain 0+


2 public DataType memberVariable; member variables.
3
A class can contain
4 public DataType memberProperty { get; set; }
0+ properties.
5
6 public MyClass() { A class can contain
7 // … Constructor logic 0+ constructors.
8 )
9 A class can contain
10 public void memberMethod() { 0+ methods.
11 //… Method logic
12 }
13 }

Accessing an Apex Class or Class Member 64

Access Modifier
Applied to a Class Applied to a Class Member
Keyword

§ Accessible to all Apex code everywhere.


global § Used to define code for asynchronous Accessible to all Apex code everywhere.
Apex and services (email, web).

Accessible within your application or Accessible within your application or


public
namespace. namespace.

Accessible to any:
§ Inner classes in the defining Apex class.
protected Not available
§ Classes that extend the defining Apex
class.

§ Applied to inner classes to make them § The default access modifier.


private accessible locally. § A private member is accessible only within
§ Can be applied to test classes. the Apex class in which it is defined.

DEFINITION: Namespace prefixes are used in managed packages to differentiate custom object
and field names from those in use by other organizations.

© Copyright 2020 salesforce.com, inc. 32


Trailhead Virtual Bootcamp for Platform Developer I

Apex Class Example 65

Apex class with public method and private helper method:


1 public class EmailManager {
2 public void sendMail(String address, String subject, String body) {
3 // Create an email message object
4 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
5 String[] toAddresses = new String[] {address};
6 mail.setToAddresses(toAddresses);
7 mail.setSubject(subject);
8 mail.setPlainTextBody(body);
9 Messaging.SendEmailResult[] results = Messaging.sendEmail(
10 new Messaging.SingleEmailMessage[] { mail });
11 inspectResults(results); // Call helper method to inspect results
12 }
13
14 // Helper method
15 private static Boolean inspectResults(Messaging.SendEmailResult[] results) {
16 . . .
17 }
18 }

APPLYING Static AND Final TO A


Applying
CLASS Static and Final to a Class Member
MEMBER 66

A class and its methods


are implicitly final by
default (no overridable).

1 public class MyClass {


2 public final Integer FINAL_VAR1;
3 public final Integer FINAL_VAR2 = 2; A static final
4 public final static Integer STATIC_FINAL_VAR3; variable can be assigned
5 public final static Integer STATIC_FINAL_VAR4 = 4; at declaration or in
6 static initialization.
7 static {
8 STATIC_FINAL_VAR3 = 3;
}
9 A final class variable
10
11 public MyClass() { can be assigned only at
12 FINAL_VAR1 = 1; declaration or in a
13 } constructor.
14 }

© Copyright 2020 salesforce.com, inc. 33


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 67

• Declarative Process Automation


• Apex Overview
• Data Types, Classes, and Methods
• Control Flow Statements
• sObjects

Conditionals and Loops 68

• If List<Integer> threeNumbers = new List<Integer>();


threeNumbers.add(1);
• If-else threeNumbers.add(2);
threeNumbers.add(3);
• Switch
Integer threeNumbersSize = threeNumbers.size();
Integer iterator = 0;

• While // A While Loop


while (iterator < threeNumbersSize) {
• Do-while System.debug('While Loop Iteration: ' + threeNumbers[iterator]);
iterator++;
}

// A traditional For loop


• For (traditional) for (iterator = 0; iterator < threeNumbersSize; iterator++) {
• For (list or set iteration) }
System.debug('For Loop Iteration: ' + threeNumbers[iterator]);

• For (iterate over


// A For loop (list or set iteration)
SOQL result) for (Integer i :threeNumbers) {
System.debug('List Loop Iteration: ' + i);
}

© Copyright 2020 salesforce.com, inc. 34


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 69

• Declarative Process Automation


• Apex Overview
• Data Types, Classes, and Methods
• Control Flow Statements
• sObjects

What is an sObject? 70

DEFINITION: sObject is a generic virtual data type that can be used to refer to any object that
can be stored in the Lightning Platform database. A data object defined in the user interface is
represented as an sObject in Apex.

1A Account acct = new Account(Name = 'Acme');


2A insert acct;

1B public void updateOffers(List<Offer__c> offerList){


2B for(Offer__c offer : offerList) {
3B if (offer.Property__r.Type__c == 'Residential') {
4B offer.Target_Close_Date__c = offer.Offer_Date__c + 45;
5B }
6B }
7B update offerList;
8B }

NOTE: Use the == operator for String equality as well as between two sObjects to determine if all
fields are equal. The === operator, when used with sObjects, checks that the operands are
referring to the same sObject.

© Copyright 2020 salesforce.com, inc. 35


Trailhead Virtual Bootcamp for Platform Developer I

Week 2 Knowledge Check 71


71

1. What is a capability of roll-up summary fields?


2. There is a master-detail relationship between the Contact object (master) and
the Certification Held object (detail). How can AW Computing track the total
number of certifications held by each service technician contact?
3. What would correctly complete the final statement?
Certification_Attempt__c certAttempt = …; //Assume this populates from the database.
String certificationElementName = _______________________________;

4. What would correctly complete the final statement?


Certification_Element__c certElement = …; //Assume this populates from the database.
List<Certification_Attempt__c> certificationAttempts = _______________________________;

5. What conditional expression would be used to determine if the contents of


two sObjects are equal?
6. Which keyword indicates a variable in a class can only be assigned at
declaration or in the class's constructors?

REVIEW SESSION
WEEK 2

Q & A

© Copyright 2020 salesforce.com, inc. 36


Trailhead Virtual Bootcamp for Platform Developer I

Week 2: Where you’ve been 73


73

• Lightning Flow Module • Salesforce Help Pages


– Choose the Right Automation Tool – Which Automation Tool Do I Use?
– Automate Simple Business Processes
with Process Builder
• Apex Basics & Database Module
– Guide Users Through Your Business
– Get Started with Apex
Processes with Flow Builder
– Use sObjects
– Combine the Power of Process Builder
and Flow Builder
– Customize How Records Get Approved • Apex Basics for Admins Module
with Approvals – Control Data Flow
– Use Loops
• Platform Development Basics Module
– Get Started with the Salesforce Platform
– Develop Without Code
– Code with Salesforce Languages
– Extend the Salesforce Platform

Week 3: Where you’re going 74


74

• Apex Basics & Database Module • Apex Developer Guide


– Manipulate Records with DML – Filter SOQL Queries Using WITH
– Write SOQL Queries SECURITY_ENFORCED
– Write SOSL Queries – Enforce Security With the
stripInaccessible Method
– Access Modifiers
• Data Leak Prevention Module
– Interfaces
– Identify and Prevent Sharing Violations – Apex Email Service
– Apex Transactions
• Apex & .NET Basics Module – Execution Governors and Limits
– Understand Execution Context

© Copyright 2020 salesforce.com, inc. 37


Trailhead Virtual Bootcamp for Platform Developer I

Trailhead Virtual Bootcamp for


Platform Developer I
Week 3 Q&A

Trailhead Virtual Bootcamp for


Platform Developer I
Instructor Session:
Week 3 Review

© Copyright 2020 salesforce.com, inc. 38


Trailhead Virtual Bootcamp for Platform Developer I

Copyright

© Copyright 2000-2020 salesforce.com, inc. All rights reserved. Various trademarks


held by their respective owners.

Rights of ALBERT EINSTEIN are used with permission of The Hebrew University of
Jerusalem. Represented exclusively by Greenlight.

This document contains proprietary information of salesforce.com, inc., it is provided


under a license agreement containing restrictions on use, duplication and disclosure
and is also protected by copyright law. Permission is granted to customers of
salesforce.com, inc. to use and modify this document for their internal business
purposes only. Resale of this document or its contents is prohibited.

The information in this document is subject to change without notice. Should you find
any problems or errors, please log a case from the Support link on the Salesforce home
page. Salesforce.com, inc. does not warrant that this document is error-free.

77

Forward Looking Statements 78

"Safe harbor" statement under the Private Securities Litigation Reform Act of 1995: This presentation contains forward-looking statements about the company's financial and
operating results, which may include expected GAAP and non-GAAP financial and other operating and non-operating results, including revenue, net income, diluted earnings
per share, operating cash flow growth, operating margin improvement, expected revenue growth, expected current remaining performance obligation growth, expected tax rates,
stock-based compensation expenses, amortization of purchased intangibles, shares outstanding, market growth, environmental, social and governance goals and expected capital
allocation, including mergers and acquisitions, capital expenditures and other investments. The achievement or success of the matters covered by such forward-looking
statements involves risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any of the assumptions prove incorrect, the company’s results could
differ materially from the results expressed or implied by the forward-looking statements it makes.
The risks and uncertainties referred to above include -- but are not limited to -- risks associated with the effect of general economic and market conditions; the impact of
geopolitical events, natural disasters and actual or threatened public health emergencies, such as the ongoing Coronavirus pandemic; the impact of foreign currency exchange
rate and interest rate fluctuations on our results; our business strategy and our plan to build our business, including our strategy to be the leading provider of enterprise cloud
computing applications and platforms; the pace of change and innovation in enterprise cloud computing services; the seasonal nature of our sales cycles; the competitive nature
of the market in which we participate; our international expansion strategy; the demands on our personnel and infrastructure resulting from significant growth in our customer
base and operations, including as a result of acquisitions; our service performance and security, including the resources and costs required to avoid unanticipated downtime and
prevent, detect and remediate potential security breaches; the expenses associated with our data centers and third-party infrastructure providers; additional data center capacity;
real estate and office facilities space; our operating results and cash flows; new services and product features, including any efforts to expand our services beyond the CRM market;
our strategy of acquiring or making investments in complementary businesses, joint ventures, services, technologies and intellectual property rights; the performance and fair
value of our investments in complementary businesses through our strategic investment portfolio; our ability to realize the benefits from strategic partnerships, joint ventures and
investments; the impact of future gains or losses from our strategic investment portfolio, including gains or losses from overall market conditions that may affect the publicly
traded companies within our strategic investment portfolio; our ability to execute our business plans; our ability to successfully integrate acquired businesses and technologies; our
ability to continue to grow unearned revenue and remaining performance obligation; our ability to protect our intellectual property rights; our ability to develop our brands; our
reliance on third-party hardware, software and platform providers; our dependency on the development and maintenance of the infrastructure of the Internet; the effect of
evolving domestic and foreign government regulations, including those related to the provision of services on the Internet, those related to accessing the Internet, and those
addressing data privacy, cross-border data transfers and import and export controls; the valuation of our deferred tax assets and the release of related valuation allowances; the
potential availability of additional tax assets in the future; the impact of new accounting pronouncements and tax laws; uncertainties affecting our ability to estimate our tax rate;
uncertainties regarding our tax obligations in connection with potential jurisdictional transfers of intellectual property, including the tax rate, the timing of the transfer and the
value of such transferred intellectual property; the impact of expensing stock options and other equity awards; the sufficiency of our capital resources; factors related to our
outstanding debt, revolving credit facility and loan associated with 50 Fremont; compliance with our debt covenants and lease obligations; current and potential litigation involving
us; and the impact of climate change.
Further information on these and other factors that could affect the company’s financial results is included in the reports on Forms 10-K, 10-Q and 8-K and in other filings it makes
with the Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of the company’s
website at.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements, except as required by law.

© Copyright 2020 salesforce.com, inc. 39


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 79

• Data Manipulation Language


• SOQL and SOSL
• Data Access Security
• Interfaces and Inheritance
• Governor Limits

Two Ways of Writing DML Commands 80

Standalone DML Database.method(sObject List)


1A Contact withName = 1B Contact withName =
new Contact(LastName = 'Hines'); new Contact(LastName = 'Hines');
2A Contact noName = new Contact(); 2B Contact noName = new Contact();
3A List<Contact> contacts = new List<Contact>(); 3B List<Contact> contacts = new List<Contact>();
4A contacts.add(withName); 4B contacts.add(withName);
5A contacts.add(noName); 5B contacts.add(noName);
6A insert contacts; 6B Database.insert(contacts);

© Copyright 2020 salesforce.com, inc. 40


Trailhead Virtual Bootcamp for Platform Developer I

Capturing Results with Database Methods 81

1 Contact withName= new Contact(LastName = 'Lee');


2 Contact noName= new Contact();
3 List<Contact> contacts = new List<Contact>();
4 contacts.add(withName);
5 contacts.add(noName);
6 List<Database.SaveResult> srs = Database.insert(contacts, false);
7
Loop processes one SaveResult
8 for (Database.SaveResult sr : srs ) { per sObject inserted.
9
10 if(sr.isSuccess() == FALSE) {
11 If an error was detected…
12 List<Database.Error> errors = sr.getErrors();
13
14 Integer i = 1;
… start processing the errors.
15 String debugString = 'Errors: ';
16 for (Database.Error e : errors) {
17 debugString += i + '. ' + e.getMessage() + '; ';
18 i++; getMessage() gets error info.
19 }
20
21 System.debug(debugString);
22 }
23 }

Options for Partial Processing 82

QUESTION: What happens if inserting the Contact "noName" causes an exception, but inserting
the Contact "withName" doesn't cause an exception?

withName noName withName noName

Standalone DML: insert contacts; Database method: Database.insert(contacts, FALSE);


Database method: Database.insert(contacts);
Database method: Database.insert(contacts, TRUE);

All of these options Partial processing only occurs when


result in "all or the optional AllorNone parameter is
none" behavior. FALSE. This also means that a failed
commit does not cause an exception.

© Copyright 2020 salesforce.com, inc. 41


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 83

• Data Manipulation Language


• SOQL and SOSL
• Data Access Security
• Interfaces and Inheritance
• Governor Limits

What is SOQL? 84

DEFINITION:
SOQL is the Salesforce Object Query Language.

SOQL allows developers to:


Use SOQL to fetch data Database
• Use selection criteria that exists in
to retrieve data from the database.
sObjects in the
Salesforce database.
List<Case> cases = [SELECT CaseNumber FROM Case];
• Integrate data
retrieval into Apex
and APIs.
Store retrieved Case
Memory data in an sObject List
in memory.

© Copyright 2020 salesforce.com, inc. 42


Trailhead Virtual Bootcamp for Platform Developer I

SOQL SELECT Syntax 85

SELECT field1, field2, …


FROM sObject
[WHERE conditionExpression]
[LIMIT numberOfRows]
[Other options, such as GROUP BY]

WHERE Clause Operator 86

WHERE Clause Operator Use


= Equals
!= Not equals
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
Wildcard search in String fields; ‘%’ matches 0+ characters. ‘_’
LIKE
matches 1+ characters
IN / NOT IN Inclusion / Exclusion
INCLUDES / EXCLUDES Inclusion and exclusion for multi-select picklists
AND Logical AND
OR Logical OR
NOT Negation

RESOURCE:
For documentation on these operators and more search for: SOQL and SOSL Reference.

© Copyright 2020 salesforce.com, inc. 43


Trailhead Virtual Bootcamp for Platform Developer I

Creating and Executing a Query at Run Time 87

Dynamic SOQL: Build a query string at run time and pass it into the
Database.query method.
String criteria = '';
Boolean lookForOpenCases = false;

if (lookForOpenCases) {
criteria = 'Status = \'Working\'';
} else {
criteria = 'ClosedDate < TODAY';
}

List<Case> theCases =
Database.query('SELECT Id, Subject FROM Case WHERE ' + criteria);
System.debug(theCases);

ALERT:
You will not know about syntax errors in the query string until run time.

Anatomy of a Simple SOSL FIND Statement 88

DEFINITION: SOSL (Salesforce Object Search Language) allows developers to search text,
email, and phone fields in multiple objects simultaneously.

Data type that


holds the
search results.

1 List<List<sObject>> acmes =
[ FIND 'Acme' IN ALL FIELDS RETURNING Account, Opportunity ];

Which type of field


What string are we Which type of data
should be
searching for? should be returned?
searched?

© Copyright 2020 salesforce.com, inc. 44


Trailhead Virtual Bootcamp for Platform Developer I

SOQL vs SOSL 89

SOQL SOSL
1. You want to count the number of
records meeting criteria.
ü
2. You want data from one object or
ü
multiple related objects
3. You don’t know which object or
ü
field the data resides in.
4. You want to sort results as part
ü ü
of the query.
5. You want data from number,
ü
date, or checkbox fields.

Lesson Agenda 90

• Data Manipulation Language


• SOQL and SOSL
• Data Access Security
• Interfaces and Inheritance
• Governor Limits

© Copyright 2020 salesforce.com, inc. 45


Trailhead Virtual Bootcamp for Platform Developer I

Review of Data Access in Salesforce 91

Profile CRED settings control access to the Field-level security further


object, Account in this example. defines access to fields.

Account Name Phone Type Industry … More fields


ABC Labs 1-408-555-2091 Customer Biotechnology …
Acme (212) 555-5555 Prospect Manufacturing …
American Package 1-302-555-9811 Consulting Shipping …

The Sharing Model


determines row-level access.

NOTE:
Object CRED and FLS are both defined on profiles and permission sets and are ignored by Apex.

An Apex Class… 92

… ignores Object CRED. … ignores FLS.

Account Name Phone Type Industry … More fields


ABC Labs 1-408-555-2091 Customer Biotechnology …
Acme (212) 555-5555 Prospect Manufacturing …
American Package 1-302-555-9811 Consulting Shipping …

… can be programmed to respect or ignore the running user's record-level


access during data operations (SOQL, DML, dot notation traversal).

© Copyright 2020 salesforce.com, inc. 46


Trailhead Virtual Bootcamp for Platform Developer I

Using the With/Without Sharing Keywords 93

1A public with sharing class RespectsSharing { Respects the Sharing Model


2A } for the running user.

1B public without sharing class IgnoresSharing { Ignores the Sharing Model


2B } for the running user.

1C public inherited sharing class UsesCallerSharing { Uses the Sharing Model of


2C } the calling Class.

Enforcing Ownership and the Sharing Model 94

A user who has Read 1A public with sharing class QueryClass {


access to 50 out of 110 2A public List<Account> fetchAccounts() {
Account records executes 3A return [SELECT Id FROM Account];
4A }
the methods to the right.
5A }

1. How many sObjects


1B public without sharing class QueryClass {
will be returned by 2B public List<Account> fetchAccounts() {
fetchAccounts() in 3B return [SELECT Id FROM Account];
the top (A) example? 4B }
5B }

2. How many sObjects


will be returned by
fetchAccounts() in
bottom (B) example?

© Copyright 2020 salesforce.com, inc. 47


Trailhead Virtual Bootcamp for Platform Developer I

Does this Class Respect the Running User's Sharing Model? 95

1A public class NoKeywordPhraseClass {


1B }

When this Class is invoked by… The Sharing Model is…

An Anonymous Block Respected


A Trigger Ignored
A Test Ignored
A Web Service Ignored
• Respected, if the invoking class is
Another Class "with sharing"
• Ignored, otherwise

Filter SOQL Queries using WITH SECURITY_ENFORCED 96

DEFINITION: Use the WITH SECURITY_ENFORCED clause to enable field and object
level security permissions checking for SOQL SELECT queries in Apex code, including
subqueries and cross-object relationships.

Matt Wilson
(end user)

1 List<Account> acct1 = [SELECT Id, (SELECT LastName FROM Contacts),


2 (SELECT Description FROM Opportunities)
3 FROM Account WITH SECURITY_ENFORCED]

© Copyright 2020 salesforce.com, inc. 48


Trailhead Virtual Bootcamp for Platform Developer I

Enforce Security with stripInaccessible 97

DEFINITION: Use the stripInaccessible method to enforce field and object level
data protection in queries or DML.

• Strip fields from query and subquery results that the user
can't access

• Remove inaccessible sObject fields before DML


operations to avoid exceptions and to sanitize sObjects
that have been deserialized from an untrusted source

Accessing an Apex Class or Class Member 98

Access Modifier
Applied to a Class Applied to a Class Member
Keyword

§ Accessible to all Apex code everywhere.


global § Used to define code for asynchronous Accessible to all Apex code everywhere.
Apex and services (email, web).

Accessible within your application or Accessible within your application or


public
namespace. namespace.

Accessible to any:
§ Inner classes in the defining Apex class.
protected Not available
§ Classes that extend the defining Apex
class.
§ The default access modifier.
§ Applied to inner classes to make them
§ A private member is accessible only
private accessible locally.
within the Apex class in which it is
§ Can be applied to test classes.
defined.

DEFINITION: Namespace prefixes are used in managed packages to differentiate custom object
and field names from those in use by other organizations.

© Copyright 2020 salesforce.com, inc. 49


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 99

• Data Manipulation Language


• SOQL and SOSL
• Data Access Security
• Interfaces and Inheritance
• Governor Limits

More Uses Cases of an Apex Class 100

Implementing inheritance using an interface:


1A public interface CustomPaginator {
1B }

2A public class AccountPaginator implements CustomPaginator {


2B }

Implementing inheritance using a virtual class:


3A public virtual class CustomPaginator {
3B }

4A public class AccountPaginator extends CustomPaginator {


4B }

NOTE: In Apex, a data type of one class can be cast to and from a data type of another class, but
only if the classes are related through inheritance.

© Copyright 2020 salesforce.com, inc. 50


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 101

• Data Manipulation Language


• SOQL and SOSL
• Data Access Security
• Interfaces and Inheritance
• Governor Limits

What are Apex Governor Limits? 102

DEFINITION: All Apex execution is bound by governor limits that the system enforces on
operations to ensure resources are available for all tenants.

A Single Apex Transaction

Method Process
§ Entry point from § Trigger implicitly
execute § Method performs fired by change § Process builder
anonymous. DML operation. to data. implicitly fired by
§ Explicitly invokes § Starts database change to data.
method. transaction.
Execute Trigger
Anonymous

ALERT: If you exceed a governor limit, your code will terminate with an unhandleable, and hence
Per Transaction: exception.
unrecoverable, Queries Database operations Heap space CPU time Other…

© Copyright 2020 salesforce.com, inc. 51


Trailhead Virtual Bootcamp for Platform Developer I

Staying Within Governor Limits When Using DML (1) 103

1 for (Contact aContact : [SELECT Id FROM Contact]) {


2 //modify aContact
3 Database.update(aContact);
4 }

1. What is the current governor limit for the total


number of DML statements issued? Use the
limits guide online to discover the answer.

2. What will happen during the execution of this


for loop if the number of records returned by
the query in line 1 exceeds the number of DML
statements allowed in a single transaction?

Staying Within Governor Limits When Using DML (2) 104

1 List<Contact> contacts = new List<Contact>();


2 for(Contact aContact : [SELECT Id from Contact]) {
3 //modify aContact
4 contacts.add(aContact);
5 }
6 Database.update(contacts);

How does this code sample solve the issues we


saw in the previous code sample?

© Copyright 2020 salesforce.com, inc. 52


Trailhead Virtual Bootcamp for Platform Developer I

Staying Within Governor Limits When Using DML (3) 105

1 for (List<Contact> contacts : [SELECT Id FROM Contact]) {


2 for (Contact aContact : contacts) {
3 //modify aContact
4 }
5 Database.update(contacts);
6 }

How does this code sample solve the issues we saw


in the previous two code samples?

Week 3 Knowledge Check 106


106

1. What happens if an operation in code exceeds a governor limit?


2. If a developer executes this query in the Query Editor of the
Developer Console, what would be the result?
SELECT * FROM Case
3. Which WHERE clause operator supports wildcards?
4. The variable queryString is assigned the string literal: 'SELECT
Name FROM Account'. How do you specify queryString as an
argument to Database.query()?
5. Which access modifier allows a class to be called anywhere in your
Salesforce organization?
6. For DML in Apex, what can you do using Database methods that
you cannot do using standalone statements?
7. What is one advantage of using static SOQL instead of dynamic
SOQL?

© Copyright 2020 salesforce.com, inc. 53


Trailhead Virtual Bootcamp for Platform Developer I

REVIEW SESSION
WEEK 3

Q & A

Week 3: Where you’ve been 108


108

• Apex Basics & Database Module • Apex Developer Guide


– Manipulate Records with DML – Filter SOQL Queries Using WITH
– Write SOQL Queries SECURITY_ENFORCED
– Write SOSL Queries – Enforce Security With the
stripInaccessible Method
– Access Modifiers
• Data Leak Prevention Module
– Interfaces
– Identify and Prevent Sharing Violations – Apex Email Service
– Apex Transactions
• Apex & .NET Basics Module – Execution Governors and Limits
– Understand Execution Context

© Copyright 2020 salesforce.com, inc. 54


Trailhead Virtual Bootcamp for Platform Developer I

Week 4: Where you’re going 109


109

• Apex Triggers Module • Visualforce Basics Module


– Get Started with Apex Triggers – Get Started with Visualforce
– Bulk Apex Triggers – Create & Edit Visualforce Pages
– Use Simple Variables and Formulas
• Apex Developer Guide – Use Standard Controllers
– Triggers and Order of Execution – Display Records, Fields, and Tables
– Create Custom Exceptions – Input Data Using Forms
– Use Standard List Controllers
– Use Static Resources
• Salesforce Help Pages – Create & Use Custom Controllers
– Call Apex Code from a Process
– Let Flows Execute Apex Actions

• Salesforce Developers Blog


– The 15 Apex Commandments

Trailhead Virtual Bootcamp for


Platform Developer I
Week 4 Q&A

© Copyright 2020 salesforce.com, inc. 55


Trailhead Virtual Bootcamp for Platform Developer I

Trailhead Virtual Bootcamp for


Platform Developer I
Instructor Session:
Week 4 Review

Copyright

© Copyright 2000-2020 salesforce.com, inc. All rights reserved. Various trademarks


held by their respective owners.

Rights of ALBERT EINSTEIN are used with permission of The Hebrew University of
Jerusalem. Represented exclusively by Greenlight.

This document contains proprietary information of salesforce.com, inc., it is provided


under a license agreement containing restrictions on use, duplication and disclosure
and is also protected by copyright law. Permission is granted to customers of
salesforce.com, inc. to use and modify this document for their internal business
purposes only. Resale of this document or its contents is prohibited.

The information in this document is subject to change without notice. Should you find
any problems or errors, please log a case from the Support link on the Salesforce home
page. Salesforce.com, inc. does not warrant that this document is error-free.

112

© Copyright 2020 salesforce.com, inc. 56


Trailhead Virtual Bootcamp for Platform Developer I

Forward Looking Statements 113

"Safe harbor" statement under the Private Securities Litigation Reform Act of 1995: This presentation contains forward-looking statements about the company's financial and
operating results, which may include expected GAAP and non-GAAP financial and other operating and non-operating results, including revenue, net income, diluted earnings
per share, operating cash flow growth, operating margin improvement, expected revenue growth, expected current remaining performance obligation growth, expected tax rates,
stock-based compensation expenses, amortization of purchased intangibles, shares outstanding, market growth, environmental, social and governance goals and expected capital
allocation, including mergers and acquisitions, capital expenditures and other investments. The achievement or success of the matters covered by such forward-looking
statements involves risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any of the assumptions prove incorrect, the company’s results could
differ materially from the results expressed or implied by the forward-looking statements it makes.
The risks and uncertainties referred to above include -- but are not limited to -- risks associated with the effect of general economic and market conditions; the impact of
geopolitical events, natural disasters and actual or threatened public health emergencies, such as the ongoing Coronavirus pandemic; the impact of foreign currency exchange
rate and interest rate fluctuations on our results; our business strategy and our plan to build our business, including our strategy to be the leading provider of enterprise cloud
computing applications and platforms; the pace of change and innovation in enterprise cloud computing services; the seasonal nature of our sales cycles; the competitive nature
of the market in which we participate; our international expansion strategy; the demands on our personnel and infrastructure resulting from significant growth in our customer
base and operations, including as a result of acquisitions; our service performance and security, including the resources and costs required to avoid unanticipated downtime and
prevent, detect and remediate potential security breaches; the expenses associated with our data centers and third-party infrastructure providers; additional data center capacity;
real estate and office facilities space; our operating results and cash flows; new services and product features, including any efforts to expand our services beyond the CRM market;
our strategy of acquiring or making investments in complementary businesses, joint ventures, services, technologies and intellectual property rights; the performance and fair
value of our investments in complementary businesses through our strategic investment portfolio; our ability to realize the benefits from strategic partnerships, joint ventures and
investments; the impact of future gains or losses from our strategic investment portfolio, including gains or losses from overall market conditions that may affect the publicly
traded companies within our strategic investment portfolio; our ability to execute our business plans; our ability to successfully integrate acquired businesses and technologies; our
ability to continue to grow unearned revenue and remaining performance obligation; our ability to protect our intellectual property rights; our ability to develop our brands; our
reliance on third-party hardware, software and platform providers; our dependency on the development and maintenance of the infrastructure of the Internet; the effect of
evolving domestic and foreign government regulations, including those related to the provision of services on the Internet, those related to accessing the Internet, and those
addressing data privacy, cross-border data transfers and import and export controls; the valuation of our deferred tax assets and the release of related valuation allowances; the
potential availability of additional tax assets in the future; the impact of new accounting pronouncements and tax laws; uncertainties affecting our ability to estimate our tax rate;
uncertainties regarding our tax obligations in connection with potential jurisdictional transfers of intellectual property, including the tax rate, the timing of the transfer and the
value of such transferred intellectual property; the impact of expensing stock options and other equity awards; the sufficiency of our capital resources; factors related to our
outstanding debt, revolving credit facility and loan associated with 50 Fremont; compliance with our debt covenants and lease obligations; current and potential litigation involving
us; and the impact of climate change.
Further information on these and other factors that could affect the company’s financial results is included in the reports on Forms 10-K, 10-Q and 8-K and in other filings it makes
with the Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of the company’s
website at.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements, except as required by law.

Lesson Agenda 114

• Triggers
• Save Order of Execution
• Invocable Apex
• Exception Handling
• Visualforce Pages
• Visualforce Controllers

© Copyright 2020 salesforce.com, inc. 57


Trailhead Virtual Bootcamp for Platform Developer I

A Trigger Provides a Code-Based Solution 115

DEFINITION: A trigger is Apex code that may execute because a DML event (insert, update,
delete, or undelete) has occurred on an sObject.

TRIGGERS

Once the platform receives a Commit

request to perform a DML


action, the platform executes
the many steps of the "Save Save

Order of Execution." Two of


the steps execute triggers.

What are the Two Types of Triggers Used For? 116

NOTE:
before triggers are used to update record values.

after triggers are used to access field values, such as Ids, that are set by the system and to
effect changes in other records.

QUESTION:
What type of trigger would you use to implement the following logic?

When a new Property has been added to the Real Estate listings, automatically post a Chatter
message to the area manager with a link to the Property record.

© Copyright 2020 salesforce.com, inc. 58


Trailhead Virtual Bootcamp for Platform Developer I

Four Key Questions to Ask Before Writing a Trigger 117

A Property is saved.
A trigger associated
This kicks off the
with the appropriate
"Save Order of
sObject is fired.
Execution."

We would like to determine if a Property


Close Date is a Holiday. The trigger
Issue an error
1. On what type of sObject does the determines: Does
Yes and don't save
DML event happen? Holiday? or the property close date
the Property
conflict with a
Property__c? record.
holiday?
2. What is the triggering DML event?
3. Should this logic be specified No
in a before trigger? or in an
after trigger? Insert or update
4. What are the expected outcomes the Property in
of the trigger? the database.

Trigger Logic can Access the Trigger Context 118

Trigger Context Variable What does it contain? Where is it available?


isInsert, Returns true, if the DML operation (e.g., isInsert) or timing (e.g.,
All triggers
isBefore, is… (etc.) isBefore) is accurate for the event.
Insert, update and
new A list of the new versions of the sObjects.
undelete triggers
before update, after insert,
newMap A map of IDs to the updated versions of the sObjects. after update, and after
undelete triggers
old A list of the previous versions of the sObjects. Update and delete triggers

oldMap A map of IDs to the previous versions of the sObjects. Update and delete triggers

isExecuting Returns true if Trigger is the current context for the Apex code All triggers

Returns a System.TriggerOperation enum response identifying


operationType All triggers
the DML operation

size Integer of the total number of records in the Trigger All triggers

NOTE: A trigger has a run-time context which can be accessed using context variables of the
System.Trigger class. The context contains information about the invoking DML event, the
data available to the trigger, and more.

© Copyright 2020 salesforce.com, inc. 59


Trailhead Virtual Bootcamp for Platform Developer I

What is in Trigger.New and Trigger.Old? 119

1 trigger PropertyTrigger on Property__c (before insert, before update) {


2 System.debug('NEW' + trigger.new);
3 System.debug('OLD' + trigger.old);
4 }

1. Create a Property
with a close date of
today.

2. Insert the 2A. What will Line 2 print?


Property. 2B. What will Line 3 print?

3. Update the
inserted Property's 3A. What will Line 2 print?
close date to today 3B. What will Line 3 print?
plus 1 month.

Lesson Agenda 120

• Triggers
• Save Order of Execution
• Invocable Apex
• Exception Handling
• Visualforce Pages
• Visualforce Controllers

© Copyright 2020 salesforce.com, inc. 60


Trailhead Virtual Bootcamp for Platform Developer I

The Save Order of Execution 121

DEFINITION:
The Save Order of Execution describes the series of events that occur on the Salesforce platform
when a record is saved.

DML Operation
Save
INTERNET
All data which
was saved
earlier is
Commit
committed to
the database.
Data is saved, Save
but not
committed.

NOTE: There is a similar series of events for delete and undelete operations.

What Features are Part of the Save Order of Execution? 122

Which declarative features might Which programmatic features might


affect or start the Save Order of affect or start the Save Order of
Execution? Execution?
a. Workflow rules a. Apex code
b. Approval processes b. Email sent from Apex code
c. Roll-up summaries c. Visualforce pages
d. Formula fields d. Lightning component
e. Processes
f. Required field

© Copyright 2020 salesforce.com, inc. 61


Trailhead Virtual Bootcamp for Platform Developer I

What Happens Before the Save to the Database? 123

Consider the following Loads the original record(s) from


the database (updating) or
scenario: initializes an sObject(s) (inserting).
§ The user saves a course
delivery record. Loads field values from the request
into the sObjects and performs
§ The record passes all System validation if from UI.
system validations.
§ A before trigger is executed. Executes all before-save
flows and before triggers.
§ System validation fails.
Runs most system Save
validation steps again and
What event is likely to have custom validations.
caused the data to become
Executes duplicate
invalid? rules.

What Happens After the Save to the Database? 124


Part 1: Triggers and Workflow Rules
1
Execute before
update triggers.
2
Commit
Execute most
System validations
(no custom).
Save 3
Save the updated
record to the
Execute database.
after triggers. Save 4
Execute after
Execute workflow update triggers.
rule. If the 1 2 3 4
workflow updates
a field… • Executing these before and after triggers can cause additional
workflow rules to execute, causing these steps to begin again.
• Custom validation rules, duplicate rules and escalation rules are not
run again.

© Copyright 2020 salesforce.com, inc. 62


Trailhead Virtual Bootcamp for Platform Developer I

What Happens After the Save to the Database? Part 2: 125


Triggers and Processes
1
Execute before
update triggers.

Commit Execute process 2


Execute most
flow rule. If the flow
System and all
updates a field…
Save custom validations.
3
Save the updated
Save record to the
database.
1 2 3 4 4
Execute after
update triggers.

The execution of these before and after triggers can cause


processes to execute against the same record in the same transaction
if the option "Reevaluate Records in the Process Builder" is chosen.

What Happens After the Save to the Database? Part 3 126

Executes post-
commit logic.

Executes Criteria-Based
Commit Sharing evaluation.

Save Performs calculation for roll-up summary


field or cross-object workflow on ancestors,
working from parent upward.

What are the consequences


of calculating a roll-up
summary field?

© Copyright 2020 salesforce.com, inc. 63


Trailhead Virtual Bootcamp for Platform Developer I

What Happens When Roll-Up Summary Invokes DML on 127


Parent?

Commit and post-commit events


occur just once, at the end of the
original process.
If an update Commit
occurs on parent
record ….
Save
PARENT RECORD

Commit
That starts another Save
set of Save Order of
Execution events. If a trigger updates a record,
which causes another trigger to
execute and update the original
record, you can potentially get
into a recursive situation.

Lesson Agenda 128

• Triggers
• Save Order of Execution
• Invocable Apex
• Exception Handling
• Visualforce Pages
• Visualforce Controllers

© Copyright 2020 salesforce.com, inc. 64


Trailhead Virtual Bootcamp for Platform Developer I

Call Apex Code from Process Builder 129

1 public class DeleteUnusedAssets {


2 @InvocableMethod
3 public static void AssetDelete(List<Account> AccountIds) {
4 List<Asset> unusedAssets =[select id from asset
5 where Account.id in :AccountIds
6 and Status = 'Obsolete'];
7 delete unusedAssets;
8 }
9 }

Lesson Agenda 130

• Triggers
• Save Order of Execution
• Invocable Apex
• Exception Handling
• Visualforce Pages
• Visualforce Controllers

© Copyright 2020 salesforce.com, inc. 65


Trailhead Virtual Bootcamp for Platform Developer I

Catching Exceptions 131

1 List<Contact> contacts = new List<Contact>();


2 Contact noName = new Contact();
3 Contact anotherNoName = new Contact();
4
5 Contacts.add(noName);
6 Contacts.add(anotherNoName); Throws an exception
7
8 try {
9 insert contacts;
10 } catch (DMLException e){ Catches a specific exception
11 System.debug('Caught DML exception: ' + e);
12 } catch (Exception e) { Catches a general exception
13 System.debug('Caught general exception: ' + e);
14 } finally { Always executes
15 System.debug(‘This block executes regardless');
16 }

NOTE: If an end user started the chain of events that resulted in an unhandled exception, the
exception will be displayed in the user interface.

Lesson Agenda 132

• Triggers
• Save Order of Execution
• Invocable Apex
• Exception Handling
• Visualforce Pages
• Visualforce Controllers

© Copyright 2020 salesforce.com, inc. 66


Trailhead Virtual Bootcamp for Platform Developer I

What is Visualforce? 133

• Visualforce markup: A tag-based markup language, similar to HTML.


1A <apex:page controller="MyController_CC" tabStyle="Account">
2A <apex:form >
3A <apex:pageBlock id="contactList" title="Verify Accounts">
4A <apex:panelGrid cellspacing="4" columns="6" >
5A …
6A </apex:pageBlock>
7A </apex:form>
8A </apex:page>

• Visualforce controllers: standard controllers or custom controllers, written in Apex.


1B public class MyController_CC {
2B private final Account account;
3B public MyController_CC() {
4B account = [SELECT Id, Name, Site FROM Account WHERE Id =
:ApexPages.currentPage().getParameters().get('id')];
5B }
6B public PageReference save() {
7B update account;
8B return null;
9B }
10B }

Visualforce Pages and the MVC 134

Out of the Box Using Visualforce

Model
Standard and Standard and
Custom Objects Custom Objects

View

Page Layouts Visualforce Pages

Controller
Standard Controller
Standard Controller Custom Controllers
Controller Extensions

© Copyright 2020 salesforce.com, inc. 67


Trailhead Virtual Bootcamp for Platform Developer I

Expression Syntax 135

Tags use the same expression syntax as formula fields and other areas of the
application. All content in {!...} is evaluated as an expression.
sObject Name Field Name

<apex:inputField value="{!Course__c.Duration__c}"/>
Contains the
expression

Global variables, whose names start with $, can be accessed using the same syntax.
For example:
• {!$User.fieldName}
• {!$Page.otherVisualforcePage}
• {!$Resource.staticResource}

How Can You Call Action Methods? 136

You can call an action in the action parameter of a variety of Visualforce tags, using the
{!...} notation. For example, this tag…
<apex:commandButton action="{!edit}"value="My Edit Button"/>

Creates this button: My Edit Button , which calls the edit method on a standard controller.

Action-Aware Tags Use Case


<apex:commandButton> Creates a button that calls an action.
<apex:commandLink> Creates a link that calls an action.
<apex:actionPoller> Periodically calls an action.
Makes an event (such as “onclick,” “onmouseover,” etc.) on
<apex:actionSupport>
another (named) component call an action.
<apex:actionFunction> Defines a new JavaScript function that calls an action.
<apex:page> Calls an action when the page is loaded.

The standard controller action methods include: save, quicksave, edit, view, delete, cancel, and list.

© Copyright 2020 salesforce.com, inc. 68


Trailhead Virtual Bootcamp for Platform Developer I

Launching Visualforce Pages 137

§ Provide the URL for the page. § Include inline in a page layout.

§ Create a custom button or link.


§ Override one of the standard actions. § Create a custom action.

§ Create a custom Visualforce tab. § Add to a Lightning App Builder page

Lesson Agenda 138

• Triggers
• Save Order of Execution
• Invocable Apex
• Exception Handling
• Visualforce Pages
• Visualforce Controllers

© Copyright 2020 salesforce.com, inc. 69


Trailhead Virtual Bootcamp for Platform Developer I

What are Visualforce Controllers? 139

DEFINITION: A Visualforce controller is a set of instructions that specify what happens when a
user interacts with the components on a Visualforce page and provide access to data. A standard
DEFINITION:

controller exists for every Salesforce object and custom controllers are written in Apex.

1 public class MyController_CC {


2 private final Account account;
3 public MyController_CC() {
4 account = [SELECT Id, Name, Site FROM Account WHERE Id =
:ApexPages.currentPage().getParameters().get('id')];
5 }
6 public PageReference save() {
7 update account;
8 return null;
9 }
10 }

Binding Data to Visualforce Controllers 140

• The standardController attribute specifies the sObject on which the page and standard controller
will operate, and the style of the tab that will display the page.
<apex:page standardController="Account">

• The Id parameter on the URL binds the page to a single record, giving it data context.
https://na1.salesforce.com/apex/myPage?id=0013000000gzexd

NOTE: The sObject Id being passed in must be for an object of the same type as that specified by
the standardController tag.

© Copyright 2020 salesforce.com, inc. 70


Trailhead Virtual Bootcamp for Platform Developer I

Traversing Data from a Standard Controller 141

You can use expression syntax to retrieve data from objects related to the current
object.

§ Traverse up five levels of child-to-parent relationships.


• Example:
1A <apex:page standardController="Contact">
2A <apex:outputField value="{!contact.Account.Owner.FirstName}">
3A </apex:page>

§ Traverse down one level of parent-to-child relationships to return a related list of


all child records for that parent.
• Example:
1B <apex:page standardController="Account">
2B <apex:pageBlock>
3B <apex:pageBlockTable value="{!account.Contacts}">
4B ...
5B </apex:page>

When Can't You Use a Standard Controller? 142

You need a custom controller or controller


extension when you must display data that is
Additional reasons to use a custom
not accessible with a standard controller. controller or controller extension:

Account
• Create custom behaviors

• Override existing functionality

One level down: • Customize the navigation


Contact Accessible with a
standard controller.

Two levels down:


Held Requires a controller extension
or custom controller.

© Copyright 2020 salesforce.com, inc. 71


Trailhead Virtual Bootcamp for Platform Developer I

What Can Controller Extensions and Custom 143


Controllers Provide?
Getter methods that allow
the view to retrieve data 1 public class TheController {
using the controller. 2 String searchText;
3 List<Lead> results;
4 public String getSearchText() {
5 return searchText;
Setter methods that allow 6 }
the view to set data in 7
8 public void setSearchText(String s) {
the controller. 9 searchText = s;
10 }
11
12 public List<Lead> Results { get; }
Properties that can be 13
used to get and set or 14 public PageReference doSearch() {
results = (List<Lead>)[ FIND :searchText
store values. 15 RETURNING Lead(Name, Email) ][0];
16 return null;
17 }
18 }
Action methods to
perform logic or
navigation.

When Must a Page Use a Controller Extension? 144

There are two reasons you must choose a controller


extension over a custom controller:

1. You want to use functionality already existing in


the standard or custom controller you are using
for the page.

2. You need to use your page with declarative


Salesforce features that depend on a standard
controller, like overriding a page layout, creating a
custom button or action, or including your page
within a page layout.

NOTE: A custom controller extension can be used with either a standard controller OR a custom
controller class.

© Copyright 2020 salesforce.com, inc. 72


Trailhead Virtual Bootcamp for Platform Developer I

Custom Controller Vs. Controller Extension. 145

QUESTION:
Should you use a custom controller or a controller extension?
Scenario Answer
1. A quick-create page, allowing the user to create Custom Controller – This doesn’t naturally use one object
an account, contact, and opportunity, all from more than the others, so a custom controller is probably the
one page. best fit, but you could also do this with one or more
extensions.
2. A page with custom functionality that can be Controller extension – You must use the standard controller
launched using a button on a page layout. to launch using a custom button.
3. A multi-page wizard, which guides a user Custom Controller – This doesn’t really relate to standard
through the process of designing a sales plan for DML operations for any one object, so a custom controller is
a new customer. a good fit.
4. A page that, on saving a new certification Controller Extension – You should use the built-in save
record, automatically redirects the user to a page functionality from the standard controller in your custom
where they can create a new related certification save method, no need to re-write it.
element.
ALERT: A custom controller must explicitly define all data and action methods that will be used
on the page, including methods already found in standard controllers if you need them.

Week 4 Knowledge Check 146


146

1. Which type of action fires a trigger?

2. In which type of trigger can you edit trigger.new?

3. In which type of trigger can the trigger context variable 'old' be used
meaningfully?

4. A developer is creating a Visualforce page that will use the standard


Account controller. Which page requirements mean the developer
must also include a Controller Extension?

5. What can be used as the basis for a Custom List Controller?

6. How can you invoke a Standard List Controller?

© Copyright 2020 salesforce.com, inc. 73


Trailhead Virtual Bootcamp for Platform Developer I

REVIEW SESSION
WEEK 4

Q & A

Week 4: Where you’ve been 148


148

• Apex Triggers Module • Visualforce Basics Module


– Get Started with Apex Triggers – Get Started with Visualforce
– Bulk Apex Triggers – Create & Edit Visualforce Pages
– Use Simple Variables and Formulas
• Apex Developer Guide – Use Standard Controllers
– Triggers and Order of Execution – Display Records, Fields, and Tables
– Create Custom Exceptions – Input Data Using Forms
– Use Standard List Controllers
– Use Static Resources
• Salesforce Help Pages – Create & Use Custom Controllers
– Call Apex Code from a Process
– Let Flows Execute Apex Actions

• Salesforce Developers Blog


– The 15 Apex Commandments

© Copyright 2020 salesforce.com, inc. 74


Trailhead Virtual Bootcamp for Platform Developer I

Week 5: Where you’re going 149


149

• Salesforce Security Guide • Quick Start: Lightning Web Components


– Security Guidelines for Apex and Visualforce Project
Development – Set Up Your Salesforce DX Environment
• Visualforce Developer Guide – Set Up Visual Studio Code
– Style Existing Visualforce Pages with Lightning – Create a Hello World Lightning Web Component
Experience Stylesheets
• Lightning Web Components Basics Module
• Aura Components Basics Module – Discover Lightning Web Components
– Get Started with Aura Components – Create Lightning Web Components
• Lightning Aura Components Developer Guide – Deploy Lightning Web Component Files
– What Is Lightning Component Framework? – Handle Events in Lightning Web Components
– Actions and Events – Add Styles and Data to a Lightning Web
– Component Events Component
– Application Events • Platform Events Basics Module
• Quick Start: Aura Components Project – Understand Event-Driven Software Architecture
– Create a Server-side Apex Controller Class – Define and Publish Platform Events
– Create an Aura Component – Subscribe to Platform Events
– Retrieve a Contact List • Einstein Next Best Action Module
– Render and Preview the Contact List – Get Started with Einstein Next Best Action

Trailhead Virtual Bootcamp for


Platform Developer I
Week 5 Q&A

© Copyright 2020 salesforce.com, inc. 75


Trailhead Virtual Bootcamp for Platform Developer I

Trailhead Virtual Bootcamp for


Platform Developer I
Instructor Session:
Week 5 Review

Copyright

© Copyright 2000-2020 salesforce.com, inc. All rights reserved. Various trademarks


held by their respective owners.

Rights of ALBERT EINSTEIN are used with permission of The Hebrew University of
Jerusalem. Represented exclusively by Greenlight.

This document contains proprietary information of salesforce.com, inc., it is provided


under a license agreement containing restrictions on use, duplication and disclosure
and is also protected by copyright law. Permission is granted to customers of
salesforce.com, inc. to use and modify this document for their internal business
purposes only. Resale of this document or its contents is prohibited.

The information in this document is subject to change without notice. Should you find
any problems or errors, please log a case from the Support link on the Salesforce home
page. Salesforce.com, inc. does not warrant that this document is error-free.

152

© Copyright 2020 salesforce.com, inc. 76


Trailhead Virtual Bootcamp for Platform Developer I

Forward Looking Statements 153

"Safe harbor" statement under the Private Securities Litigation Reform Act of 1995: This presentation contains forward-looking statements about the company's financial and
operating results, which may include expected GAAP and non-GAAP financial and other operating and non-operating results, including revenue, net income, diluted earnings
per share, operating cash flow growth, operating margin improvement, expected revenue growth, expected current remaining performance obligation growth, expected tax rates,
stock-based compensation expenses, amortization of purchased intangibles, shares outstanding, market growth, environmental, social and governance goals and expected capital
allocation, including mergers and acquisitions, capital expenditures and other investments. The achievement or success of the matters covered by such forward-looking
statements involves risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any of the assumptions prove incorrect, the company’s results could
differ materially from the results expressed or implied by the forward-looking statements it makes.
The risks and uncertainties referred to above include -- but are not limited to -- risks associated with the effect of general economic and market conditions; the impact of
geopolitical events, natural disasters and actual or threatened public health emergencies, such as the ongoing Coronavirus pandemic; the impact of foreign currency exchange
rate and interest rate fluctuations on our results; our business strategy and our plan to build our business, including our strategy to be the leading provider of enterprise cloud
computing applications and platforms; the pace of change and innovation in enterprise cloud computing services; the seasonal nature of our sales cycles; the competitive nature
of the market in which we participate; our international expansion strategy; the demands on our personnel and infrastructure resulting from significant growth in our customer
base and operations, including as a result of acquisitions; our service performance and security, including the resources and costs required to avoid unanticipated downtime and
prevent, detect and remediate potential security breaches; the expenses associated with our data centers and third-party infrastructure providers; additional data center capacity;
real estate and office facilities space; our operating results and cash flows; new services and product features, including any efforts to expand our services beyond the CRM market;
our strategy of acquiring or making investments in complementary businesses, joint ventures, services, technologies and intellectual property rights; the performance and fair
value of our investments in complementary businesses through our strategic investment portfolio; our ability to realize the benefits from strategic partnerships, joint ventures and
investments; the impact of future gains or losses from our strategic investment portfolio, including gains or losses from overall market conditions that may affect the publicly
traded companies within our strategic investment portfolio; our ability to execute our business plans; our ability to successfully integrate acquired businesses and technologies; our
ability to continue to grow unearned revenue and remaining performance obligation; our ability to protect our intellectual property rights; our ability to develop our brands; our
reliance on third-party hardware, software and platform providers; our dependency on the development and maintenance of the infrastructure of the Internet; the effect of
evolving domestic and foreign government regulations, including those related to the provision of services on the Internet, those related to accessing the Internet, and those
addressing data privacy, cross-border data transfers and import and export controls; the valuation of our deferred tax assets and the release of related valuation allowances; the
potential availability of additional tax assets in the future; the impact of new accounting pronouncements and tax laws; uncertainties affecting our ability to estimate our tax rate;
uncertainties regarding our tax obligations in connection with potential jurisdictional transfers of intellectual property, including the tax rate, the timing of the transfer and the
value of such transferred intellectual property; the impact of expensing stock options and other equity awards; the sufficiency of our capital resources; factors related to our
outstanding debt, revolving credit facility and loan associated with 50 Fremont; compliance with our debt covenants and lease obligations; current and potential litigation involving
us; and the impact of climate change.
Further information on these and other factors that could affect the company’s financial results is included in the reports on Forms 10-K, 10-Q and 8-K and in other filings it makes
with the Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of the company’s
website at.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements, except as required by law.

Lesson Agenda 154

• SOQL Injection
• Visualforce Pages in Lightning
• Aura Components
• Lightning Component Events
• Lightning Web Components
• Platform Events
• Next Best Action

© Copyright 2020 salesforce.com, inc. 77


Trailhead Virtual Bootcamp for Platform Developer I

SOQL Injection 155

DEFINITION: SOQL injection involves modifying a SOQL statement to trick the application into
performing unintended commands.

An injection can happen when user-supplied input is not validated before using it
in a dynamic SOQL query. Visualforce provides tools to mitigate this common
security risk. Consider this code that creates a dynamic query:
1A String qryString = 'SELECT Id FROM Contact WHERE ' + '(Name like \'%' + name + '%\')';
2A queryResult = Database.query(qryString);

When a user supplies the value Bob as input, the resultant query is:
1B SELECT Id FROM Contact WHERE (Name like '%Bob%')

However, an unexpected value such as test% ') OR (Name LIKE ' results in:
1C SELECT Id FROM Contact WHERE (Name LIKE '%test%') OR (Name LIKE '%')

… which unintentionally displays all Contacts!

SOQL Injection Defenses 156

§ Use static queries and binding variables if possible.


The previous code can be rewritten like this:
1 String queryName = '%' + name + '%';
2 queryResult = [SELECT Id FROM Contact WHERE Name like :queryName];

§ If dynamic SOQL is required, use methods such as


String.escapeSingleQuotes to sanitize user-supplied input.

© Copyright 2020 salesforce.com, inc. 78


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 157

• SOQL Injection
• Visualforce Pages in Lightning
• Aura Components
• Lightning Component Events
• Lightning Web Components
• Platform Events
• Next Best Action

Visualforce Page: Classic vs. Lightning Styling 158

TIP: Toggle Classic or Lightning styling with lightingStylesheets page attribute.

Classic UI Lightning UI
lightningStylesheets="false" lightningStylesheets="true"

© Copyright 2020 salesforce.com, inc. 79


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 159

• SOQL Injection
• Visualforce Pages in Lightning
• Aura Components
• Lightning Component Events
• Lightning Web Components
• Platform Events
• Next Best Action

What is the Lightning Component Framework? 160

DEFINITION:
The Lightning Component framework is a UI framework for developing responsive, dynamic web
apps that run on the Salesforce platform and can easily access data in a Salesforce org.

A framework is responsive when:

• It uses relative sizing.

• It allows for the application of different styles based


on the context.

• It uses flexible scaling for images and media.


A framework is responsive when:
§ It uses relative sizing.
NOTE: § It allows for the application of different styles based on the context.
§ It uses flexible scaling for images and media.
As of Spring 19 (API version 45.0), you can build Lightning components using two programming
models: the Lightning Web Components model, and the original Aura Components model.

© Copyright 2020 salesforce.com, inc. 80


Trailhead Virtual Bootcamp for Platform Developer I

Aura Components Architecture 161

Client Server
Application Apex Class A component has a
client-side controller
Component @AuraEnabled method written in JavaScript.

A server-side
controller, written in
Apex, allows the
MARKUP CONTROLLER component to access
your Salesforce data.

Choosing Between a Visualforce Page and a Lightning 162


Application

Visualforce: Lightning:
• Page-centric • App-centric (single-page apps)
• Stateful servers • Stateless servers
• Stateless clients • Stateful clients
• Great for web pages accessed • Great for mobile app development
via desktop

© Copyright 2020 salesforce.com, inc. 81


Trailhead Virtual Bootcamp for Platform Developer I

Lightning Components are Modular 163

§ A component maybe an Aura or a


Application (has a URL) Lightning Web Component
Component § A component may contain another
Component component BUT a Lightning Web
component cannot contain an Aura
component
§ An application cannot contain another
application
§ A custom Lightning Application can only
be created using Aura
Component
Apex
@AuraEnabled

Lightning Data
Services

Resources in an Aura Component Bundle 164

The COMPONENT resource contains


markup for the view’s presentation.

The CONTROLLER handles events in the


component’s markup with client-side JavaScript.

JavaScript HELPER functions may be called from any


other JavaScript in the component bundle.

The STYLE applies CSS only to


its component’s markup.

There are additional resources you can explore


through the Lightning Component Developer Guide.

© Copyright 2020 salesforce.com, inc. 82


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 165

• SOQL Injection
• Visualforce Pages in Lightning
• Aura Components
• Lightning Component Events
• Lightning Web Components
• Platform Events
• Next Best Action

Raising and Handling Events in Aura Components 166

Two types of events in the Lightning framework:


• Component events are handled by the component itself or a
component that instantiates or contains the component.
• Application events are essentially a traditional publish-subscribe
model. All components that provide a handler for the event are
notified when the event is fired.

How It Works:
− Event-driven programming is used in many languages and frameworks, such as
JavaScript.
− You write handlers that respond to user and system events as they occur.
− A component registers that it may fire an event in its markup.
− Events are fired from JavaScript controller actions, typically triggered by a user
through the user interface.

© Copyright 2020 salesforce.com, inc. 83


Trailhead Virtual Bootcamp for Platform Developer I

Creating, Raising, and Handling a Custom Event 167

• A component event is fired from an instance of a component.


• Component events can be handled by either the component that fired the
event or a component in the containment hierarchy that receives the
bubbled event.
• The basic steps to creating, raising, and handling a custom event include:
1 2 3 4
Define a custom Register the custom Raise custom events Define event
event using the events for use in a from a client-side listeners for the
Developer Console. component using the controller or helper by raised event in
<aura:registerEvent> invoking the event.fire() your client-side
tag. function. controller.

Registering and Raising an Application Event 168

• Defining an Application event is


<aura:event type="APPLICATION">
similar to defining a component <aura:attribute
event. The only thing that changes is name="contactId"
the type property in the <aura:event> type="Id"/>
tag. </aura:event>

• Registering an Application event is


similar to raising a component event,
however you do not need to specify
the name attribute in the
<aura:registerEvent> command.

• Use the aura:registerEvent component <aura:registerEvent


to ensure that the event metadata has name="onAppStudentSelected"
downloaded from Salesforce Platform. type="c:AppStudentSelected "/>

© Copyright 2020 salesforce.com, inc. 84


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 169

• SOQL Injection
• Visualforce Pages in Lightning
• Aura Components
• Lightning Component Events
• Lightning Web Components
• Platform Events
• Next Best Action

Evolution of the Web Stack 170

2014 2019
Lightning Component Framework and Lightning Web Components
Aura programming model launched launched

Web Standards

Renaissance

© Copyright 2020 salesforce.com, inc. 85


Trailhead Virtual Bootcamp for Platform Developer I

What are Lightning Web Components? 171

• A new programming model for


building Lightning components that
leverages the web standards
breakthroughs of the last five years

• Provides a layer of specialized


Salesforce services on top of the
core stack

• Can coexist and interoperate with


the Aura model

• Unparalleled performance

Which Files to Include? 172

myComponent UI Component Service Component


• Required • Required
• JavaScript • JavaScript
myComponent.html • Metadata • Metadata
• HTML
myComponent.js • CSS (optional)
• SVG Icon (optional)
myComponent.css

myComponent.js-meta.xml

© Copyright 2020 salesforce.com, inc. 86


Trailhead Virtual Bootcamp for Platform Developer I

Defining a Lightning Web Component in VS Code 173

• Open Exercises | main | default


• Right-click on lwc
• Select:

SFDX: Create Lightning Web Component

• Enter a component name

Basic UI Component - HTML File 174

Custom Wrapper of Core module for


the standard HTML Lightning Web
element Components
childComponent.js
1 import { LightningElement } from 'lwc';
2 export default class ChildComponent extends LightningElement {}

parentComponent.html
1 <template> Mix HTML markup with
2 <div>Hello World!</div> components
3 <c-child-component></c-child-component>
4 </template>

NOTE:
The template element is used to declare fragments of HTML that can be rendered at runtime.

© Copyright 2020 salesforce.com, inc. 87


Trailhead Virtual Bootcamp for Platform Developer I

Lesson Agenda 175

• SOQL Injection
• Visualforce Pages in Lightning
• Aura Components
• Lightning Component Events
• Lightning Web Components
• Platform Events
• Next Best Action

What is a Platform Event? 176

DEFINITION: Platform events simplify the process of communicating changes in data and
enable developers to deliver secure, scalable, and customizable event notifications within
DEFINITION:

Salesforce or from external sources based on a publish-subscribe architecture.

HIGHLIGHTS:
• Platform Event messages enable near real-time
integration between Salesforce and external systems.
• Apex triggers can subscribe to Platform Events that were
published through Apex or APIs.
• Platform Events are similar to custom objects and can be
defined in the same way.

© Copyright 2020 salesforce.com, inc. 88


Trailhead Virtual Bootcamp for Platform Developer I

Event-Driven Software Architecture

Event: a change in state that is meaningful


Event Event Event
in a business process.
Producer Producer Producer
Event Message: a message that contains
data about the event.
Event Producer: the publisher of an event
message over an event bus.
Event Bus (Channel): a stream of events
on which an event producer sends event
messages and event consumers read those
messages. Also known as a channel. Event Event
Event consumer: a subscriber to an event Consumer Consumer
bus that receives messages from the
event bus.

Lesson Agenda 178

• SOQL Injection
• Visualforce Pages in Lightning
• Aura Components
• Lightning Component Events
• Lightning Web Components
• Platform Events
• Next Best Action

© Copyright 2020 salesforce.com, inc. 89


Trailhead Virtual Bootcamp for Platform Developer I

Einstein Next Best Action 179

DEFINITION: Einstein Next Best Action is a tool that surfaces recommendations to users based
on predefined criteria.

CLICK PATH:
Setup | Process Automation | Next Best Action

Week 5 Knowledge Check 180


180

1. How can a developer enable a Lightning Web Component to be


available to Lightning App Builder?

2. When making a call to an Apex method from a Lightning Web


Component how may a developer enable client side caching?

3. Which of the following code snippets is syntactically correct?

4. Which keyword phrase ensures an Apex class has access to all


the records in the database?

5. Which fields can you search using SOSL?

© Copyright 2020 salesforce.com, inc. 90


Trailhead Virtual Bootcamp for Platform Developer I

REVIEW SESSION
WEEK 5

Q & A

Week 5: Where you’ve been 182


182

• Salesforce Security Guide • Quick Start: Lightning Web Components


– Security Guidelines for Apex and Visualforce Project
Development – Set Up Your Salesforce DX Environment
• Visualforce Developer Guide – Set Up Visual Studio Code
– Style Existing Visualforce Pages with Lightning – Create a Hello World Lightning Web Component
Experience Stylesheets
• Lightning Web Components Basics Module
• Aura Components Basics Module – Discover Lightning Web Components
– Get Started with Aura Components – Create Lightning Web Components
• Lightning Aura Components Developer Guide – Deploy Lightning Web Component Files
– What Is Lightning Component Framework? – Handle Events in Lightning Web Components
– Actions and Events – Add Styles and Data to a Lightning Web
– Component Events Component
– Application Events • Platform Events Basics Module
• Quick Start: Aura Components Project – Understand Event-Driven Software Architecture
– Create a Server-side Apex Controller Class – Define and Publish Platform Events
– Create an Aura Component – Subscribe to Platform Events
– Retrieve a Contact List • Einstein Next Best Action Module
– Render and Preview the Contact List – Get Started with Einstein Next Best Action

© Copyright 2020 salesforce.com, inc. 91


Trailhead Virtual Bootcamp for Platform Developer I

Week 6: Where you’re going 183


183

• Apex Testing Module • Quick Start: Salesforce DX Project


– Get Started with Apex Unit Tests – Set Up Your Salesforce DX Environment
– Test Apex Triggers – Set Up the Project on Your Local Machine
– Create Test Data for Apex Tests – Create and Test Our Scratch Org
• Developer Console Basics Module • Salesforce DX Developer Guide
– Generate and Analyze Logs – Release Your App to Production
– Inspect Objects at Checkpoints • Change Set Development Model Module
• Salesforce Help Pages – Plan for Changes to Your Org
– Troubleshoot Processes with Apex Debug – Develop and Test Changes Locally
Logs – Test in the Integration Environment and
– Troubleshoot Flows Deploy Changes
• Asynchronous Apex Module • Metadata API Developer Guide
– Asynchronous Processing Basics – Unsupported Metadata Types
– Monitor Asynchronous Apex • Data Management Module
• Apex Developer Guide – Import Data
– Testing and Code Coverage – Export Data
– Using the Ant Migration Tool to Deploy
Changes

Trailhead Virtual Bootcamp for


Platform Developer I
Week 6 Q&A

© Copyright 2020 salesforce.com, inc. 92


Trailhead Virtual Bootcamp for Platform Developer I

Trailhead Virtual Bootcamp for


Platform Developer I
Instructor Session:
Week 6 Review

Copyright

© Copyright 2000-2020 salesforce.com, inc. All rights reserved. Various trademarks


held by their respective owners.

Rights of ALBERT EINSTEIN are used with permission of The Hebrew University of
Jerusalem. Represented exclusively by Greenlight.

This document contains proprietary information of salesforce.com, inc., it is provided


under a license agreement containing restrictions on use, duplication and disclosure
and is also protected by copyright law. Permission is granted to customers of
salesforce.com, inc. to use and modify this document for their internal business
purposes only. Resale of this document or its contents is prohibited.

The information in this document is subject to change without notice. Should you find
any problems or errors, please log a case from the Support link on the Salesforce home
page. Salesforce.com, inc. does not warrant that this document is error-free.

186

© Copyright 2020 salesforce.com, inc. 93


Trailhead Virtual Bootcamp for Platform Developer I

Forward Looking Statements 187

"Safe harbor" statement under the Private Securities Litigation Reform Act of 1995: This presentation contains forward-looking statements about the company's financial and
operating results, which may include expected GAAP and non-GAAP financial and other operating and non-operating results, including revenue, net income, diluted earnings
per share, operating cash flow growth, operating margin improvement, expected revenue growth, expected current remaining performance obligation growth, expected tax rates,
stock-based compensation expenses, amortization of purchased intangibles, shares outstanding, market growth, environmental, social and governance goals and expected capital
allocation, including mergers and acquisitions, capital expenditures and other investments. The achievement or success of the matters covered by such forward-looking
statements involves risks, uncertainties and assumptions. If any such risks or uncertainties materialize or if any of the assumptions prove incorrect, the company’s results could
differ materially from the results expressed or implied by the forward-looking statements it makes.
The risks and uncertainties referred to above include -- but are not limited to -- risks associated with the effect of general economic and market conditions; the impact of
geopolitical events, natural disasters and actual or threatened public health emergencies, such as the ongoing Coronavirus pandemic; the impact of foreign currency exchange
rate and interest rate fluctuations on our results; our business strategy and our plan to build our business, including our strategy to be the leading provider of enterprise cloud
computing applications and platforms; the pace of change and innovation in enterprise cloud computing services; the seasonal nature of our sales cycles; the competitive nature
of the market in which we participate; our international expansion strategy; the demands on our personnel and infrastructure resulting from significant growth in our customer
base and operations, including as a result of acquisitions; our service performance and security, including the resources and costs required to avoid unanticipated downtime and
prevent, detect and remediate potential security breaches; the expenses associated with our data centers and third-party infrastructure providers; additional data center capacity;
real estate and office facilities space; our operating results and cash flows; new services and product features, including any efforts to expand our services beyond the CRM market;
our strategy of acquiring or making investments in complementary businesses, joint ventures, services, technologies and intellectual property rights; the performance and fair
value of our investments in complementary businesses through our strategic investment portfolio; our ability to realize the benefits from strategic partnerships, joint ventures and
investments; the impact of future gains or losses from our strategic investment portfolio, including gains or losses from overall market conditions that may affect the publicly
traded companies within our strategic investment portfolio; our ability to execute our business plans; our ability to successfully integrate acquired businesses and technologies; our
ability to continue to grow unearned revenue and remaining performance obligation; our ability to protect our intellectual property rights; our ability to develop our brands; our
reliance on third-party hardware, software and platform providers; our dependency on the development and maintenance of the infrastructure of the Internet; the effect of
evolving domestic and foreign government regulations, including those related to the provision of services on the Internet, those related to accessing the Internet, and those
addressing data privacy, cross-border data transfers and import and export controls; the valuation of our deferred tax assets and the release of related valuation allowances; the
potential availability of additional tax assets in the future; the impact of new accounting pronouncements and tax laws; uncertainties affecting our ability to estimate our tax rate;
uncertainties regarding our tax obligations in connection with potential jurisdictional transfers of intellectual property, including the tax rate, the timing of the transfer and the
value of such transferred intellectual property; the impact of expensing stock options and other equity awards; the sufficiency of our capital resources; factors related to our
outstanding debt, revolving credit facility and loan associated with 50 Fremont; compliance with our debt covenants and lease obligations; current and potential litigation involving
us; and the impact of climate change.
Further information on these and other factors that could affect the company’s financial results is included in the reports on Forms 10-K, 10-Q and 8-K and in other filings it makes
with the Securities and Exchange Commission from time to time. These documents are available on the SEC Filings section of the Investor Information section of the company’s
website at.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements, except as required by law.

Lesson Agenda 188

• Testing Apex Code


• Debugging and Monitoring
• Development and Deployment Tools
• Data Import and Export

© Copyright 2020 salesforce.com, inc. 94


Trailhead Virtual Bootcamp for Platform Developer I

Application Lifecycle Management: Testing Apex Code 189

In our sandbox, I've created a number of


triggers and classes for my application.
Before I can deploy this code to Develop
production, I need to ensure:
• 75% of Apex code must be executed
successfully by test methods.
Test
• Every Apex trigger must have some
coverage in test methods, even though
every line of every trigger does not
have to be executed by a test.
Deploy
• Every Apex test method must execute
without throwing any uncaught
exceptions or exceeding governors.

What is an Apex Test Method 190

DEFINITION:
An Apex test method verifies whether a particular piece of Apex code is working as expected.

Business Logic

Test Method Test Method

Test Method Test Method


Business Logic

1 @isTest
2 private class MyBusinessLogicClass_Test {
3 @isTest
4 private static void myBusinessLogicTest() {
5 //… test Apex classes and triggers
6 }
7 }

© Copyright 2020 salesforce.com, inc. 95


Trailhead Virtual Bootcamp for Platform Developer I

Create an Apex Test Method Inside an Apex Test Class 191

Use _Test as the suffix


Tells the platform the following for the name of a test
class will only be used for testing. class (recommended).

A test class should 1 @isTest


2 private class MyBusinessLogicClass_Test {
be private. 3 @testSetup
4 private static void myTestDataFactory(){
5 //… Create local test data
@isTest tells the 6 }
testing framework 7 @isTest
8 private static void myBusinessLogicTest(){
that this method is
9 //… test saved Apex code
a test. Not all 10 }
methods in a test 11 }
class need to be
test methods. A test method must be static.

Creating Test Data in a Test Factory Class vs. Method 192

§ Test data "factories" can be made accessible to all test methods within an app or just
to test methods in a particular test class.
§ When localized, a test data factory method annotated with @testSetup executes
before any other method in the test class and provides data to all the test methods
in the test class.
When would you use the test data factory class over the method, and vice versa?
1A @isTest 1B @isTest
2A public class MyTestDataFactory { 2B private class MyBusinessLogicClass_Test {
3A static void insertTestAccounts() { 3B @testSetup
4A //… create and insert Accounts 4B private static void myTestDataFactory() {
5A } 5B //… create and insert Accounts
6A static void insertTestContacts() { 6B //… create and insert Contacts
7A //… create and insert Contacts 7B //… create and insert Holidays
8A } 8B //… Etc…
9A static void insertTestHolidays() { 9B }
10A //… create and insert Holidays 10B @isTest private static void myTestMethod1() {
11A } 11B //… Use the test data created above
12A } 12B }
13B @isTest private static void myTestMethod2() {
14B //… Also uses the test data created above
15B }
16B }

© Copyright 2020 salesforce.com, inc. 96


Trailhead Virtual Bootcamp for Platform Developer I

Loading Test Data Declaratively Using a Static Resource 193

Loads test data from a


Static Resource.

List<Holiday> holidays = Test.loadData(Holiday.sObjectType, 'Test_Holidays');

Static Static Resource name =


Resource 'Test_Holidays'

Name,ActivityDate First line must be


column headers.
Holiday 1,2015-01-01
Holiday 2,2015-07-04
Holiday 3,2015-11-11

CSV file

Loading Related Data Using a Static Resource 194

User-specified fake Id field and data.


Course

Parent: Course
Id Name
1 Test Course 1
Course
Delivery 2 Test Course 2

Child: Course Delivery


Course__c Id Name
1 101 Test Course Delivery 1
User-specified foreign-
key field and data. 2 201 Test Course Delivery 2
2 301 Test Course Delivery 3

© Copyright 2020 salesforce.com, inc. 97


Trailhead Virtual Bootcamp for Platform Developer I

Using Live Data to Test 195

NOTE: The class and method annotation @isTest(seeAllData = true), allows you to create
test classes and test methods that have access to all data in the org.

QUESTION:
Why do you think this is not a standard practice?

1 @isTest(seeAllData = true)
2 private class MyBusinessLogicClass_Test {
3 @isTest private static void myBusinessLogicTest() {
4 List<Holiday> holidays = [SELECT … ];
5 }
6 }

How is Code Coverage Calculated? 196

Running tests causes the code coverage percentages to be calculated.


Code coverage percentage =
(number of covered lines) / (number of covered lines + uncovered lines)
Only executable lines of code are included.
You create a test method that
only enters the first branch of 1 // Logic for the AccountTrigger (before insert)
2 public class AccountTriggerHandler {
the conditional. 3 public static void printPhone(List<Account> accounts) {
4 String debugString;
1. What is the total number 5 for (Account a :accounts){ When you test a
of lines in the 6 debugString = a.Name + ': '; condition that
AccountTriggerHandler 7 if (a.Phone == NULL) { executes only one
8 debugString += 'Null Phone';
class that need to be 9 } else {
branch of a
covered to achieve 100% 10 debugString += a.Phone; conditional, you will
code coverage? 11 } only "get credit" for
12 System.debug(debugString); testing that branch,
2. How many lines did your 13 } and not the entire
test cover? 14 }
conditional.
15 }
3. What is the code coverage Not Counted Counted
percentage for that test?

© Copyright 2020 salesforce.com, inc. 98


Trailhead Virtual Bootcamp for Platform Developer I

Testing Limits 197

1 @isTest
startTest and stopTest 2 private class AClass_Test {
methods: 3 @isTest private static void myClassTestUser() {
4 Account anAccount = new Account (name = 'Salesforce');
5 insert anAccount;
• Are used, in conjunction 6 System.debug(Limits.getDMLStatements());
with methods of the Limits 7
8
Test.startTest(); // Starts a brand new set of limits
System.debug(Limits.getDMLStatements());
class, to validate how close 9 Test.stopTest(); // Ends the set of limits started on line 7
your business logic code is 10 System.debug(Limits.getDMLStatements());
11 }
to exceeding governor 12 }
limits.
QUESTIONS:
• Demarcate the boundaries
What will line 6 print in the debug log?
of your actual test code
What will line 8 print in the debug log?
within a test method.
What will line 10 print in the debug log?
• Provide a new context (i.e.,
an entirely new set of
governor limits).

Testing with Sharing Using System.RunAs(User u) 198

System.runAs(User u) enables you to write test methods that allow you to


specify the user context so that the user’s record sharing is enforced.

1 @isTest
2 private class MyClass_Test {
3 @testSetup
4 private static void testDataSetup() {
5 Profile p = // Write a query to select a profile
6 User u = new User(Lastname = 'Foo', ProfileId = p.id);
7 insert u;
8 }
9
10 @isTest private static void myClassTestUser() {
11 User testUser = // Find Foo, who has set up above
12 System.runAs(testUser) {
13 // Now, the rest of test runs as testUser.
14 // Otherwise the test would run as System.
15 }
16 }
17 )

© Copyright 2020 salesforce.com, inc. 99


Trailhead Virtual Bootcamp for Platform Developer I

Apex in Execute Anonymous vs. Unit Tests 199

HOW THEY EXECUTE UNIT


ARE DIFFERENT… ANONYMOUS TEST
typical use case debug log output code coverage
changes to data get saved do not get saved
user permissions enforced ignored
running user or can
code executes as running user
use System.RunAs
subject to normal can reset with
governor limits
synchronous limits Test.startTest

Lesson Agenda 200

• Testing Apex Code


• Debugging and Monitoring
• Development and Deployment Tools
• Data Import and Export

© Copyright 2020 salesforce.com, inc. 100


Trailhead Virtual Bootcamp for Platform Developer I

Customizing the Debug Log 201

When using the Developer Console or monitoring a debug log, you can specify the
level of information that gets included in the log.

§ Log category: The type of information logged, such as information from Apex or
workflow rules.

§ Log level: The amount of information logged.

§ Event type: The combination of log category and log level that specify which
events get logged. Each event can log additional information, such as the line and
character number where the event started, fields associated with the event, and
duration of the event.

NOTE:
The debug log does not include information from actions triggered by time-based workflows.

Customizing the Debug Log (Continued) 202

CUSTOMIZING THE DEBUG LOG (CONTINUED)

Log levels, from lowest to highest:


Log categories:
NONE
§ Database ERROR
§ Workflow WARN
§ Callout INFO
DEBUG
§ Apex code
FINE
§ Apex profiling FINER
§ Visualforce FINEST
§ System

© Copyright 2020 salesforce.com, inc. 101


Trailhead Virtual Bootcamp for Platform Developer I

Monitor Asynchronous Apex 203

CLICK PATH:
Setup | Environments | Jobs | Apex Jobs

Run Flow in Debug Mode 204

1
3

© Copyright 2020 salesforce.com, inc. 102


Trailhead Virtual Bootcamp for Platform Developer I

Monitor Flows and Processes 205

Pending Processes and Paused Flows can both be seen


in the Paused and Waiting Interview Queue ...

CLICK PATH:
Setup | Process Automation | Paused Flow Interviews

Lesson Agenda 206

• Testing Apex Code


• Debugging and Monitoring
• Development and Deployment Tools
• Data Import and Export

© Copyright 2020 salesforce.com, inc. 103


Trailhead Virtual Bootcamp for Platform Developer I

What Can a Developer Tool Do? 207

Setup Developer
Capability SFDX
Menu Console
Create and edit Apex classes and triggers. ü ü ü
Execute anonymous Apex code. ü ü

Create and edit Visualforce pages. ü ü ü

Create and edit Lightning Components. ü ü

View debug logs. ü ü ü

Run Apex tests. ü ü ü

Run queries and view the results. ü ü

View the schema. ü ü ü

Modify the schema. ü ü

Create a sandbox. ü

What is a Sandbox? 208

DEFINITION: A sandbox is a replica of your production organization that allows you to develop
and test in a separate environment without risking or compromising data.

Sandbox Production
Deploy Changes

Create/Refresh Apex

Develop and Test

• You may not make programmatic changes directly into a production org. You must create
code in a Sandbox and then move (deploy) to production.
• Data Loader can be used to upload test data (not metadata) into sandboxes.

© Copyright 2020 salesforce.com, inc. 104


Trailhead Virtual Bootcamp for Platform Developer I

Sandbox Types 209

Type Features
Full Sandbox § Copies the entire production organization, including the metadata and data.
§ Has a storage limit based on its production organization.
§ Can be refreshed every 29 days.

Partial Data § Copies the metadata and the data defined in a sandbox template from the
Sandbox production organization.
§ Has a storage limit of 5GB of data and a maximum of 10,000 records per
selected object.
§ Can be refreshed every 5 days.

Developer Pro § Copies only the metadata from the production organization.
Sandbox § Does not copy data, but you can load up to 1GB of data separately.
§ Can be refreshed once per day.
Developer § Copies only the metadata from the production organization.
Sandbox § Does not copy data, but you can load up to 200MB of data separately.
§ Can be refreshed once per day.

What Can a Deployment Tool Do? 210

Salesforce DX Force.com
Capability Change Sets
CLI Migration Tool

Deploy changes from one org to a related org. ü ü ü

Deploy changes from one org to an unrelated org. ü ü

Modify and delete metadata. ü ü

Manage changes in a source-code control system. ü ü

Validate that dependent objects are present in the


ü ü ü
target org or included in the deployment.

Verify that 75% of Apex scripts are covered by


ü ü ü
unit tests, and the tests complete successfully.

Deploy changes using an automated script. ü ü

© Copyright 2020 salesforce.com, inc. 105


Trailhead Virtual Bootcamp for Platform Developer I

Deployment Considerations 211

• Customizations and code are • Deployed metadata overwrites


available through the Metadata existing metadata; it isn’t merged.
API as XML files.
• Renamed metadata components are
• Metadata includes the version of seen by the incoming system as new
the Apex run time engine. components.

• Unsupported metadata types must • User references are maintained


be manually re-created instead of during a metadata deployment.
deployed.

RESOURCE:

Lesson Agenda 212

• Testing Apex Code


• Debugging and Monitoring
• Development and Deployment Tools
• Data Import and Export

© Copyright 2020 salesforce.com, inc. 106


Trailhead Virtual Bootcamp for Platform Developer I

DATA MANAGEMENT
Data Management USING
Using theTHE
DataDATA IMPORT
Import WizardWIZARD 213

Use the Data Import Wizard When You Need to:

Import fewer than 50,000 records.


Prevent duplicates when importing records.
Choose whether or not to trigger workflow rules.

Match Record by Salesforce ID,


Supported Objects
External-Unique ID or:
Accounts Name & Site
Contacts Name or Email
Leads Name or Email
Solutions Title
Campaign Members N/A

Custom Objects Name

DATA MANAGEMENT
Data Management USING
Using the THE
API API 214

Use the API When You Need to:

Load unlimited number of records.

Load objects not supported by the Data Import Wizard.

Schedule imports.
Save mappings for later use.
Export or delete data.

NOTE:
Salesforce Data Loader uses the API.

© Copyright 2020 salesforce.com, inc. 107


Trailhead Virtual Bootcamp for Platform Developer I

Apply Your Knowledge of Importing and Exporting Data 215

Questions Answers
1. AW Computing needs to export 50 1. Data Loader. Data Loader supports exports for all
Opportunities. Which tool should be used? standard and custom objects. Import Wizard does not
support exports for any objects. Also, Import Wizard
supports imports for Accounts, Contacts, Leads,
Solutions, Campaign Members, and custom objects. It
cannot be used with Opportunities or other standard
objects not mentioned above.
2. AW Computing needs to import 2,000 2. Import Wizard. With Import Wizard you can choose
leads without triggering any workflow rules. whether or not to trigger workflow rules. Data Loader
Which tool should be used? does not support this option.
3. AW Computing would like to import 50 3. They must import the Accounts before the related
new Accounts and their associated Contacts Contacts. Parent records must always be imported
into Salesforce from CSV files. Which before child records.
records should be imported first?

Week 6 Knowledge Check 216


216

1. What can you use to implement inheritance among Apex classes?

2. What percentage of Apex code must be executed by test methods?

3. Which annotation for a method in a test class indicates that it will be


run once before any of the class’s test methods are executed?

4. In a test method, an Integer variable named x has the value 10.


When the statement System.Assert(x == 10); is executed in
the method, what is the outcome?

5. What can a SOSL search return?

© Copyright 2020 salesforce.com, inc. 108


Trailhead Virtual Bootcamp for Platform Developer I

REVIEW SESSION
WEEK 6

Q & A

Week 6: Where you’ve been 218


218

• Apex Testing Module • Quick Start: Salesforce DX Project


– Get Started with Apex Unit Tests – Set Up Your Salesforce DX Environment
– Test Apex Triggers – Set Up the Project on Your Local Machine
– Create Test Data for Apex Tests – Create and Test Our Scratch Org
• Developer Console Basics Module • Salesforce DX Developer Guide
– Generate and Analyze Logs – Release Your App to Production
– Inspect Objects at Checkpoints • Change Set Development Model Module
• Salesforce Help Pages – Plan for Changes to Your Org
– Troubleshoot Processes with Apex Debug – Develop and Test Changes Locally
Logs – Test in the Integration Environment and
– Troubleshoot Flows Deploy Changes
• Asynchronous Apex Module • Metadata API Developer Guide
– Asynchronous Processing Basics – Unsupported Metadata Types
– Monitor Asynchronous Apex • Data Management Module
• Apex Developer Guide – Import Data
– Testing and Code Coverage – Export Data
– Using the Ant Migration Tool to Deploy
Changes

© Copyright 2020 salesforce.com, inc. 109


Trailhead Virtual Bootcamp for Platform Developer I

Recommended Training 219

Related Instructor-Led Training:

• Programmatic Development using Apex and Visualforce in


Lightning Experience (DEX450) – 5 days

• Certification Preparation for Platform Developer I


(CRT450) - 1 day

Join the Trailblazer Community

Want to stay connected? Join the Developer or Admin Trailblazer Community


and collaborate with other Developers and Admins.

• Go to https://success.salesforce.com

• Login using any Salesforce account

• Search for Admin Trailblazers or


Developer Trailblazers

• Scroll down to Groups and click on


your group name

NOTE:
The Developer Trailblazers group is a good resource for programmatic questions. The
Admin Trailblazers group focuses on solving problems with clicks not code.

© Copyright 2020 salesforce.com, inc. 110


Trailhead Virtual Bootcamp for Platform Developer I

Thanks for Attending!


221

Your opinion matters, and we want to hear from you. Navigate to the
Class Survey provided to give us your feedback.

What’s Next?
LEARN ALL THE SKILLS YOU NEED
Build on your skills with self-paced learning or another expert-led class.
https://sfdc.co/learnsalesforce

EARN SKILL-BASED CREDENTIALS


Get rewarded for the skills you learn and get industry-wide recognition
for your expertise.
https://trailhead.salesforce.com/credentials/

CONNECT WITH FELLOW TRAILBLAZERS


Community: https://trailblazer.salesforce.com
Twitter: @Trailhead
Facebook: /SalesforceTrailhead

© Copyright 2020 salesforce.com, inc.


All rights reserved. Various trademarks
held by their respective owners.

© Copyright 2020 salesforce.com, inc. 111

You might also like