SlideShare a Scribd company logo
Show Flow 
Dreamforce 2104 Breakout Session Show Flow Template 
Notes 
Introduction to Development on Force.com 
for Developers 
2hr 30min 
Presentation Device: 
Customer Speaker: 
Demo Device 
Deck Owner/Filename: 
0:00 Doors open 
0:00 Start 
5 min 0:05 Welcome and Intros 
3 min 0:08 Agenda and workbook 
5 min 0:13 Platform Overview 
5 min 0:18 Sign up for a DE 
Please encourage all attendees to sign up for a new DE so they don’t run into 
any issues with disabled features or API naming issues 
25 min 0:43 Writing an Apex Class 
Here we only have slides, but feel free to show your own use case or demo if you have 
one 
17 min 1:00 Hands-On: Apex 
15 min 1:15 SOQL and DML Demo using SOQL in the developer console. Build your own SOQL query and talk it out 
15 min 1:30 Hands-On: SOQL/DML 
20 min 1:50 Visualforce Demo Twitter bootstrap in VF/yelp demo or your own demo 
15 min 2:05 Hands-On: Visualforce 
10min 2:15 Controller Extensions 
10 min 2:25 Hands-On: Controller Extensions 
5 min 2:30 Q&A 
There is a 30 minute turnaround time in the room, so the Q&A can extend this 
time if necessary. Also please encourage people to ask questions frequently 
throughout the day, and to utilize the helpers in the room.
Introduction to Development on 
Force.com 
For Developers Samantha Ready, salesforce.com 
Senior Developer Evangelist 
@samantha_ready
Samantha Ready 
Senior Developer Evangelist 
@samantha_ready
Safe Harbor 
Safe harbor statement under the Private Securities Litigation Reform Act of 1995: 
This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the 
assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we 
make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, 
subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements 
of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. 
The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new 
products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays 
in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and 
acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and 
manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization 
and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our 
annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on 
the SEC Filings section of the Investor Information section of our Web site. 
Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be 
delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. 
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
Go Social! 
@salesforcedevs 
Salesforce Developers 
Salesforce Developers 
Salesforce Developers 
+Salesforce Developers
Agenda 
• Platform Overview 
•Writing Apex Classes 
• Accessing Data using SOQL 
•Writing Triggers 
•Writing Visualforce Pages 
•Writing Controller Extensions 
Extra Credit: 
• Using the REST APIs 
• Unit Testing 
• Batching and Scheduling
bit.ly/df14-intro-force
Salesforce Platform is the Fastest Path from Idea to App 
Idea 
buy & 
setup 
hardware 
Idea Build App 
install 
complex 
software 
define user 
access 
build & test 
security 
make it 
mobile & 
social 
setup 
reporting & 
analytics 
build 
app 
Traditional Platforms 
6-12 Months? 
App 
App
Marketing 
Cloud 
AppExchange 
Salesforce1 App 
Salesforce1 Platform APIs 
Salesforce1 Platform Services 
Salesforce1 Platform 
Sales 
Cloud 
Service 
Cloud 
Custom 
Apps 
Partner 
Apps 
Force.com Heroku Exact Target
Salesforce1 Mobile App 
• Salesforce on your phone 
• Customizable by 
– Users 
– Admins 
– Developers 
• Supports 
– Objects 
– Visualforce 
– Canvas
Two Approaches to Development 
Declarative Approach Programmatic Approach 
Visualforce Pages 
Visualforce Components 
Apex Controllers 
Apex Triggers 
Metadata API 
REST API 
Bulk API 
Page Layouts 
Record Types 
Formula Fields 
Validation Rules 
Workflows and Approvals 
Custom Objects 
Custom Fields 
Relationships 
User 
Interface 
Business 
Logic 
Data 
Model
The Conference App 
What we’ll build… 
• Manage sessions and speakers 
• Automatically send confirmation emails 
• Customized user interface with Visualforce Pages 
• Upload speaker pictures 
• Flickr integration (Apex) to show conference pictures
Free Developer Environment 
http://developer.salesforce.com/signup 
bit.ly/df14-intro-force
Lab 1: Install Your Developer Org 
http://developer.salesforce.com/signup
Writing Apex Classes
What is Apex? 
• Salesforce platform language 
• Similar to Java 
• Object-oriented 
• Strongly typed 
• Classes and Interfaces 
• Cloud based compiling, debugging and unit testing
Apex and Java 
Same 
• Primitive data types 
• Flow control (if, for, while, …) 
• Exception handling 
• Collections: Lists, Sets, … 
Different 
• Case insensitive 
• Single quote strings: 'Joe' 
• Id data type 
• Built-in support for data access
Apex Class 
public class MortgageCalculator { 
} 
public Double amount { get; set; } 
public Double rate { get; set; } 
public Integer years { get; set; } 
public Double calculateMonthlyPayment() { 
Integer months = years * 12; 
Double monthlyRate = rate / (12 * 100); 
return amount * (monthlyRate/ 
(1 - Math.pow(1 + monthlyRate, -months))); 
}
Development Tools 
• Developer Console 
• Force.com IDE (Eclipse Plugin) 
• Mavens Mate (Sublime Plugin) 
• Force CLI
Developer Console 
• Browser Based IDE 
• Create Classes, Triggers, Pages 
• Execute Apex Anonymously 
• Execute SOQL Queries 
• Run Unit Tests 
• Review Debug Logs
Lab 4: Creating an Apex Class 
• Create the EmailManager class 
• Send emails from the developer console
Accessing Data with 
SOQL and DML
What's SOQL? 
• Salesforce Object Query language 
• Similar to SQL 
• Streamlined syntax to traverse object relationships 
• Built into Apex 
• Query results returned as nested objects
SELECT Id, Name, Phone 
FROM Contact
SELECT Id, Name, Phone 
FROM Contact 
WHERE Phone != null
SELECT Id, Name, Phone 
FROM Contact 
WHERE Phone != null 
AND Name LIKE '%rose%'
SELECT Id, Name, Phone 
FROM Contact 
WHERE Phone != null 
AND Name LIKE '%rose%' 
ORDER BY Name
SELECT Id, Name, Phone 
FROM Contact 
WHERE Phone != null 
AND Name LIKE '%rose%' 
ORDER BY Name 
LIMIT 50
Details to Master 
SELECT Id, Name, Phone, Account.Name 
FROM Contact 
WHERE Phone != null 
AND Name LIKE '%rose%' 
ORDER BY Name 
LIMIT 50
Master to Details 
SELECT Name, 
(SELECT FirstName, LastName, Phone 
FROM Contacts) 
FROM Account
Demo: Executing SOQL in the Developer Console
Inlining SOQL in Apex 
Integer i = [SELECT Count() FROM Session__c];
Inlining SOQL in Apex 
String level = 'Advanced'; 
List<Session__c> sessions = 
[SELECT Name, Level__c FROM Session__c 
WHERE Level__c = :level];
Inlining SOQL in Apex 
List<String> levels = new List<String>(); 
levels.add('Intermediate'); 
levels.add('Advanced'); 
List<Session__c> sessions = 
[SELECT Name, Level__c FROM Session__c 
WHERE Level__c IN :levels];
Inlining SOQL in Apex 
for (Speaker__c s : [select email__c from Speaker__c]) 
{ 
System.debug(s.email__c); 
}
What's DML? 
• Data Manipulation Language 
• Language used to create, update, delete records
insert 
Session__c session = new Session__c(); 
session.name = 'Apex 101'; 
session.level__c = 'Beginner'; 
insert session;
insert 
Session__c session = new Session__c( 
name = 'Apex 201', 
level__c = 'Intermediate' 
); 
insert session;
update 
String oldName = 'Apex 101'; 
String newName = 'Apex for Beginners'; 
Session__c session = 
[SELECT Id, Name FROM Session__c 
WHERE Name=:oldName]; 
session.name = newName; 
update session;
delete 
String name = 'Testing 501'; 
Session__c session = 
[SELECT Name FROM Session__c 
WHERE Name=:name]; 
delete session;
Lab 5: Accessing Data using SOQL and DML 
• Execute SOQL statements in the Query Editor 
• Execute DML statements in the Anonymous Window
Writing Triggers
What's a Trigger? 
• Apex code executed on database events 
• Before or after: 
– Insert 
– Update 
– Delete 
– Undelete
Before or After? 
• Before 
– Update or validate values before they are saved to the database 
– Example: Prevent double-booking of a speaker 
• After 
– Need access to values set by the database (Id, lastUpdated, …) 
– Example: Send speaker confirmation email
Bulk Mode 
• Trigger API is designed to support bulk operations 
– Data Import, Bulk API, etc. 
• Triggers work on bulk of records, not single records 
• Context variables provide access to data: 
– Trigger.old and Trigger.new (List) 
– Trigger.oldMap and Trigger.newMap (Map)
Example 1 
trigger WelcomeKit on Account (after insert) { 
List<Case> myCases = new List<Case>(); 
for (Account account : Trigger.new) { 
Case welcomeCase = new Case(); 
welcomeCase.Subject = 'Mail Welcome Kit'; 
welcomeCase.AccountId = account.Id; 
myCases.add(welcomeCase); 
} 
insert myCases; 
}
Example 2 
Trigger on Account (before update) { 
for (Account acc: Trigger.New) { 
// Compare new value with old value 
if (acc.Rating != Trigger.oldMap.get(acc.Id).Rating) { 
// Your Logic 
} 
} 
}
Workflow vs Trigger 
Workflow Trigger 
Created with Clicks Code 
What can it do • Update field 
• Send email 
• Create task 
• Send outbound message 
• Launch flow (flow trigger) 
~ Anything (e.g. 
create/delete records, REST 
callout, etc.) 
Cross-object field updates Limited (detail -> master) Any
Lab 6: Writing Triggers 
• Write the SendConfirmationEmail trigger 
• Write the RejectDoubleBooking trigger
Writing Visualforce 
Pages
What's a Visualforce Page? 
• HTML page with tags executed at the server-side to generate dynamic content 
• Similar to JSP and ASP 
• Can leverage JavaScript and CSS libraries 
• The View in MVC architecture
Model-View-Controller 
Model 
Data + Rules 
Controller 
View-Model 
interactions 
View 
UI code 
 Separation of concerns 
– No data access code in view 
– No view code in controller 
 Benefits 
– Minimize impact of changes 
– More reusable components
Model-View-Controller in Salesforce 
View 
• Metadata 
• Standard Pages 
• Visualforce Pages 
• External apps 
Controller 
• Metadata 
• Standard Controllers 
• Controller Extensions 
• Custom Controllers 
Model 
• Metadata 
• Objects 
• Triggers (Apex) 
• Classes (Apex)
Expression Language 
• Anything inside of {! } is evaluated as an expression 
– Dynamic variables: {!Contact.Phone} or {!myApexVariable} 
– Logic: {! IF (Opportunity.Stage == ‘Closed/Won’, val_if_true, val_if_false)} 
– Functions: {!JSENCODE(Account.BillingAddress)} 
• Same expression language as Formulas 
• $ provides access to global variables (User, Page, RemoteAction, Resource, …) 
– {! $User.FirstName } {! $User.LastName }
Example 1 
<apex:page> 
<h1>Hello, {!$User.FirstName}</h1> 
</apex:page>
Example 2 
<apex:page standardController="Contact"> 
<apex:form> 
Standard controller 
object 
<apex:inputField value="{!contact.firstname}"/> 
<apex:inputField value="{!contact.lastname}"/> 
<apex:commandButton action="{!save}" value="Save"/> 
</apex:form> 
</apex:page> Function in 
standard controller
Standard Controller 
• A standard controller is available for all objects 
– You don't have to write it! 
– No test methods needed 
– Can grab a single record or set of records 
• Provides standard CRUD operations 
– Create, Update, Delete, Field Access, etc. 
• Can be extended with more capabilities (next module) 
• Uses id query string parameter in URL to access object
Component Library 
• Presentation tags 
– <apex:pageBlock title="My Account Contacts"> 
• Fine grained data tags 
– <apex:outputField value="{!contact.firstname}"> 
– <apex:inputField value="{!contact.firstname}"> 
• Coarse grained data tags 
– <apex:detail> 
– <apex:pageBlockTable> 
• Action tags 
– <apex:commandButton action="{!save}" >
Demo: Dissect a 
Visualforce Page & 
Build with Bootstrap
Email 
Templates 
Embedded in Page 
Layouts 
Generate PDFs 
Custom Tabs Mobile 
Interfaces 
Page Overrides 
Where can I use Visualforce?
Lab 7: Writing Visualforce Pages 
• Write the SpeakerForm Visualforce page 
• Set it as default for creating and editing speakers
Writing Controller 
Extensions and Custom 
Controllers
What's a Controller Extension? 
• Custom class written in Apex 
• Works on the same object as the standard controller 
• Can override standard controller behavior 
• Can add new capabilities
Defining a Controller Extension 
<apex:page standardController="Speaker__c" 
extensions="SpeakerCtrlExt, ext2"> 
Provides basic 
CRUD 
Overrides standard 
actions and/or provide 
additional capabilities
Anatomy of a Controller Extension 
public class SpeakerCtrlExt { 
private final Speaker__c speaker; 
private ApexPages.StandardController stdController; 
public SpeakerCtrlExt (ApexPages.StandardController ctrl) { 
this.stdController = ctrl; 
this.speaker = (Speaker__c)ctrl.getRecord(); 
} 
// method overrides 
// custom methods 
}
Demo: Dissect a 
Controller Extension
What's a Custom Controller? 
• Custom class written in Apex 
• Doesn't work on a specific object 
• Provides custom data 
• Provides custom behaviors
Defining a Custom Controller 
<apex:page controller="FlickrController">
Custom Controller Example 
public with sharing class FlickrController { 
public FlickrList getPictures() { 
HttpRequest req = new HttpRequest(); 
req.setMethod('GET'); 
req.setEndpoint('http://api.flickr.com/services/feeds/'); 
HTTP http = new HTTP(); 
HTTPResponse res = http.send(req); 
return (FlickrList) JSON.deserialize(res.getBody(), 
FlickrList.class); 
} 
}
Lab 8: Writing a Controller Extension 
• Write a Controller Extension that supports Picture Upload
Samantha Ready 
Senior Developer Evangelist 
@samantha_ready 
Survey 
bit.ly/df-how-introforce
Hands-On Workshop: Introduction to Development on Force.com for Developers
Certification Logos for “Speaker Intro Slides” 
For salesforce.com 
use only 
Guides for logo placement
Example of a Table 
Table subtitle 
Column title Column title Column title Column title 
0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00
Example of a Table 
Table style and coloring 
Column title Column title Column title Column title 
0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00 
0.00 0.00 0.00 0.00
Device Family Without Screens

More Related Content

PPTX
Introduction to Point-and-Click App Building
POTX
Hands-on Workshop: Intermediate Development with Heroku and Force.com
PPTX
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
PPTX
Dev day paris020415
PPTX
Lightning Experience with Visualforce Best Practices
PDF
Visual Workflow Overview
PPTX
Salesforce Lightning workshop
PPTX
Drive Productivity with Salesforce and Microsoft Exchange and Outlook
Introduction to Point-and-Click App Building
Hands-on Workshop: Intermediate Development with Heroku and Force.com
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
Dev day paris020415
Lightning Experience with Visualforce Best Practices
Visual Workflow Overview
Salesforce Lightning workshop
Drive Productivity with Salesforce and Microsoft Exchange and Outlook

What's hot (17)

PPTX
Practical Headless Flow Examples
PDF
Increase Adoption By Building Lightning Pages
PPT
Vf ppt (1)
PDF
Customizing sales force-interface
PPTX
Cloud flow designer: Salesforce.com
PPT
Salesforce Presentation
PPT
Salesforce Integration with PHP
PPTX
Salesforce for Beginners
PDF
Salesforce Interview Questions And Answers | Salesforce Tutorial | Salesforce...
PDF
Keeping it Simple with Permission Sets
DOCX
Customize the login homepage For Oracle EBS R12
PDF
Introducing: The Lightning Experience
PDF
Summer '16 Release Preview Webinar
PPTX
Mastering Salesforce Person Account
PDF
Intro to Force.com Webinar presentation
PDF
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
PDF
Force.com migration utility
Practical Headless Flow Examples
Increase Adoption By Building Lightning Pages
Vf ppt (1)
Customizing sales force-interface
Cloud flow designer: Salesforce.com
Salesforce Presentation
Salesforce Integration with PHP
Salesforce for Beginners
Salesforce Interview Questions And Answers | Salesforce Tutorial | Salesforce...
Keeping it Simple with Permission Sets
Customize the login homepage For Oracle EBS R12
Introducing: The Lightning Experience
Summer '16 Release Preview Webinar
Mastering Salesforce Person Account
Intro to Force.com Webinar presentation
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Force.com migration utility
Ad

Viewers also liked (13)

PPTX
Atl elevate programmatic developer slides
DOCX
Interview questions
PPTX
Triggers for Admins: A Five-step Framework for Creating Triggers
ODP
Workflow in Salesforce
PPTX
Deep Dive into Apex Triggers
PDF
Apex code-fundamentals
PPTX
Apex for Admins: Get Started with Apex in 30 Minutes! (part 1)
PDF
Intro to Apex Programmers
PPTX
Apex basics-for Beginners
PPTX
Introduction to Apex for Developers
DOCX
Sfdc Knowledge
PPTX
Salesforce Multitenant Architecture: How We Do the Magic We Do
PPTX
Salesforce Basic Development
Atl elevate programmatic developer slides
Interview questions
Triggers for Admins: A Five-step Framework for Creating Triggers
Workflow in Salesforce
Deep Dive into Apex Triggers
Apex code-fundamentals
Apex for Admins: Get Started with Apex in 30 Minutes! (part 1)
Intro to Apex Programmers
Apex basics-for Beginners
Introduction to Apex for Developers
Sfdc Knowledge
Salesforce Multitenant Architecture: How We Do the Magic We Do
Salesforce Basic Development
Ad

Similar to Hands-On Workshop: Introduction to Development on Force.com for Developers (20)

PDF
Elevate london dec 2014.pptx
PDF
Our API Evolution: From Metadata to Tooling API for Building Incredible Apps
PPTX
Elevate Tel Aviv
PPTX
Salesforce Campus Tour - Developer Intro
DOCX
salesforce_4+_years_exp
PDF
Dreamforce 2017: Salesforce DX - an Admin's Perspective
PDF
Lightning web components - Episode 1 - An Introduction
PDF
Spring '16 Release Preview Webinar
PPTX
Integrating with salesforce
PPTX
TrailheaDX and Summer '19: Developer Highlights
PPTX
Elevate Madrid Essentials - Advance Track
DOCX
RubaDevi_Salesforce
PPTX
5 free admin tools to make your life easier - Tel Aviv, Israel Admin Group
PPTX
01 #awesome admin tdx19 global gatherings highlights for admins final
PDF
Salesforce Admin Group-Barcelona-2022-07-05 In-person Meetup-BCN Admins Group
PPTX
Building Command-line Tools with the Tooling API
DOC
Ashish-SFDC-10-16
PPTX
Salesforce Lightning workshop Hartford - 12 March
PDF
Spring '14 Release Developer Preview Webinar
PPT
Build your API with Force.com and Heroku
Elevate london dec 2014.pptx
Our API Evolution: From Metadata to Tooling API for Building Incredible Apps
Elevate Tel Aviv
Salesforce Campus Tour - Developer Intro
salesforce_4+_years_exp
Dreamforce 2017: Salesforce DX - an Admin's Perspective
Lightning web components - Episode 1 - An Introduction
Spring '16 Release Preview Webinar
Integrating with salesforce
TrailheaDX and Summer '19: Developer Highlights
Elevate Madrid Essentials - Advance Track
RubaDevi_Salesforce
5 free admin tools to make your life easier - Tel Aviv, Israel Admin Group
01 #awesome admin tdx19 global gatherings highlights for admins final
Salesforce Admin Group-Barcelona-2022-07-05 In-person Meetup-BCN Admins Group
Building Command-line Tools with the Tooling API
Ashish-SFDC-10-16
Salesforce Lightning workshop Hartford - 12 March
Spring '14 Release Developer Preview Webinar
Build your API with Force.com and Heroku

More from Salesforce Developers (20)

PDF
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
PDF
Maximizing Salesforce Lightning Experience and Lightning Component Performance
PDF
Local development with Open Source Base Components
PPTX
TrailheaDX India : Developer Highlights
PDF
Why developers shouldn’t miss TrailheaDX India
PPTX
CodeLive: Build Lightning Web Components faster with Local Development
PPTX
CodeLive: Converting Aura Components to Lightning Web Components
PPTX
Enterprise-grade UI with open source Lightning Web Components
PDF
Live coding with LWC
PDF
Lightning web components - Episode 4 : Security and Testing
PDF
LWC Episode 3- Component Communication and Aura Interoperability
PDF
Lightning web components episode 2- work with salesforce data
PDF
Migrating CPQ to Advanced Calculator and JSQCP
PDF
Scale with Large Data Volumes and Big Objects in Salesforce
PDF
Replicate Salesforce Data in Real Time with Change Data Capture
PDF
Modern Development with Salesforce DX
PDF
Get Into Lightning Flow Development
PDF
Integrate CMS Content Into Lightning Communities with CMS Connect
PDF
Introduction to MuleSoft
PDF
Modern App Dev: Modular Development Strategies
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Local development with Open Source Base Components
TrailheaDX India : Developer Highlights
Why developers shouldn’t miss TrailheaDX India
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Converting Aura Components to Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
Live coding with LWC
Lightning web components - Episode 4 : Security and Testing
LWC Episode 3- Component Communication and Aura Interoperability
Lightning web components episode 2- work with salesforce data
Migrating CPQ to Advanced Calculator and JSQCP
Scale with Large Data Volumes and Big Objects in Salesforce
Replicate Salesforce Data in Real Time with Change Data Capture
Modern Development with Salesforce DX
Get Into Lightning Flow Development
Integrate CMS Content Into Lightning Communities with CMS Connect
Introduction to MuleSoft
Modern App Dev: Modular Development Strategies

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Electronic commerce courselecture one. Pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
KodekX | Application Modernization Development
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Modernizing your data center with Dell and AMD
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Machine learning based COVID-19 study performance prediction
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
Review of recent advances in non-invasive hemoglobin estimation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Electronic commerce courselecture one. Pdf
Digital-Transformation-Roadmap-for-Companies.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Diabetes mellitus diagnosis method based random forest with bat algorithm
The AUB Centre for AI in Media Proposal.docx
KodekX | Application Modernization Development
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Modernizing your data center with Dell and AMD
“AI and Expert System Decision Support & Business Intelligence Systems”
20250228 LYD VKU AI Blended-Learning.pptx
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25 Week I
Machine learning based COVID-19 study performance prediction
The Rise and Fall of 3GPP – Time for a Sabbatical?
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Advanced methodologies resolving dimensionality complications for autism neur...

Hands-On Workshop: Introduction to Development on Force.com for Developers

  • 1. Show Flow Dreamforce 2104 Breakout Session Show Flow Template Notes Introduction to Development on Force.com for Developers 2hr 30min Presentation Device: Customer Speaker: Demo Device Deck Owner/Filename: 0:00 Doors open 0:00 Start 5 min 0:05 Welcome and Intros 3 min 0:08 Agenda and workbook 5 min 0:13 Platform Overview 5 min 0:18 Sign up for a DE Please encourage all attendees to sign up for a new DE so they don’t run into any issues with disabled features or API naming issues 25 min 0:43 Writing an Apex Class Here we only have slides, but feel free to show your own use case or demo if you have one 17 min 1:00 Hands-On: Apex 15 min 1:15 SOQL and DML Demo using SOQL in the developer console. Build your own SOQL query and talk it out 15 min 1:30 Hands-On: SOQL/DML 20 min 1:50 Visualforce Demo Twitter bootstrap in VF/yelp demo or your own demo 15 min 2:05 Hands-On: Visualforce 10min 2:15 Controller Extensions 10 min 2:25 Hands-On: Controller Extensions 5 min 2:30 Q&A There is a 30 minute turnaround time in the room, so the Q&A can extend this time if necessary. Also please encourage people to ask questions frequently throughout the day, and to utilize the helpers in the room.
  • 2. Introduction to Development on Force.com For Developers Samantha Ready, salesforce.com Senior Developer Evangelist @samantha_ready
  • 3. Samantha Ready Senior Developer Evangelist @samantha_ready
  • 4. Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  • 5. Go Social! @salesforcedevs Salesforce Developers Salesforce Developers Salesforce Developers +Salesforce Developers
  • 6. Agenda • Platform Overview •Writing Apex Classes • Accessing Data using SOQL •Writing Triggers •Writing Visualforce Pages •Writing Controller Extensions Extra Credit: • Using the REST APIs • Unit Testing • Batching and Scheduling
  • 8. Salesforce Platform is the Fastest Path from Idea to App Idea buy & setup hardware Idea Build App install complex software define user access build & test security make it mobile & social setup reporting & analytics build app Traditional Platforms 6-12 Months? App App
  • 9. Marketing Cloud AppExchange Salesforce1 App Salesforce1 Platform APIs Salesforce1 Platform Services Salesforce1 Platform Sales Cloud Service Cloud Custom Apps Partner Apps Force.com Heroku Exact Target
  • 10. Salesforce1 Mobile App • Salesforce on your phone • Customizable by – Users – Admins – Developers • Supports – Objects – Visualforce – Canvas
  • 11. Two Approaches to Development Declarative Approach Programmatic Approach Visualforce Pages Visualforce Components Apex Controllers Apex Triggers Metadata API REST API Bulk API Page Layouts Record Types Formula Fields Validation Rules Workflows and Approvals Custom Objects Custom Fields Relationships User Interface Business Logic Data Model
  • 12. The Conference App What we’ll build… • Manage sessions and speakers • Automatically send confirmation emails • Customized user interface with Visualforce Pages • Upload speaker pictures • Flickr integration (Apex) to show conference pictures
  • 13. Free Developer Environment http://developer.salesforce.com/signup bit.ly/df14-intro-force
  • 14. Lab 1: Install Your Developer Org http://developer.salesforce.com/signup
  • 16. What is Apex? • Salesforce platform language • Similar to Java • Object-oriented • Strongly typed • Classes and Interfaces • Cloud based compiling, debugging and unit testing
  • 17. Apex and Java Same • Primitive data types • Flow control (if, for, while, …) • Exception handling • Collections: Lists, Sets, … Different • Case insensitive • Single quote strings: 'Joe' • Id data type • Built-in support for data access
  • 18. Apex Class public class MortgageCalculator { } public Double amount { get; set; } public Double rate { get; set; } public Integer years { get; set; } public Double calculateMonthlyPayment() { Integer months = years * 12; Double monthlyRate = rate / (12 * 100); return amount * (monthlyRate/ (1 - Math.pow(1 + monthlyRate, -months))); }
  • 19. Development Tools • Developer Console • Force.com IDE (Eclipse Plugin) • Mavens Mate (Sublime Plugin) • Force CLI
  • 20. Developer Console • Browser Based IDE • Create Classes, Triggers, Pages • Execute Apex Anonymously • Execute SOQL Queries • Run Unit Tests • Review Debug Logs
  • 21. Lab 4: Creating an Apex Class • Create the EmailManager class • Send emails from the developer console
  • 22. Accessing Data with SOQL and DML
  • 23. What's SOQL? • Salesforce Object Query language • Similar to SQL • Streamlined syntax to traverse object relationships • Built into Apex • Query results returned as nested objects
  • 24. SELECT Id, Name, Phone FROM Contact
  • 25. SELECT Id, Name, Phone FROM Contact WHERE Phone != null
  • 26. SELECT Id, Name, Phone FROM Contact WHERE Phone != null AND Name LIKE '%rose%'
  • 27. SELECT Id, Name, Phone FROM Contact WHERE Phone != null AND Name LIKE '%rose%' ORDER BY Name
  • 28. SELECT Id, Name, Phone FROM Contact WHERE Phone != null AND Name LIKE '%rose%' ORDER BY Name LIMIT 50
  • 29. Details to Master SELECT Id, Name, Phone, Account.Name FROM Contact WHERE Phone != null AND Name LIKE '%rose%' ORDER BY Name LIMIT 50
  • 30. Master to Details SELECT Name, (SELECT FirstName, LastName, Phone FROM Contacts) FROM Account
  • 31. Demo: Executing SOQL in the Developer Console
  • 32. Inlining SOQL in Apex Integer i = [SELECT Count() FROM Session__c];
  • 33. Inlining SOQL in Apex String level = 'Advanced'; List<Session__c> sessions = [SELECT Name, Level__c FROM Session__c WHERE Level__c = :level];
  • 34. Inlining SOQL in Apex List<String> levels = new List<String>(); levels.add('Intermediate'); levels.add('Advanced'); List<Session__c> sessions = [SELECT Name, Level__c FROM Session__c WHERE Level__c IN :levels];
  • 35. Inlining SOQL in Apex for (Speaker__c s : [select email__c from Speaker__c]) { System.debug(s.email__c); }
  • 36. What's DML? • Data Manipulation Language • Language used to create, update, delete records
  • 37. insert Session__c session = new Session__c(); session.name = 'Apex 101'; session.level__c = 'Beginner'; insert session;
  • 38. insert Session__c session = new Session__c( name = 'Apex 201', level__c = 'Intermediate' ); insert session;
  • 39. update String oldName = 'Apex 101'; String newName = 'Apex for Beginners'; Session__c session = [SELECT Id, Name FROM Session__c WHERE Name=:oldName]; session.name = newName; update session;
  • 40. delete String name = 'Testing 501'; Session__c session = [SELECT Name FROM Session__c WHERE Name=:name]; delete session;
  • 41. Lab 5: Accessing Data using SOQL and DML • Execute SOQL statements in the Query Editor • Execute DML statements in the Anonymous Window
  • 43. What's a Trigger? • Apex code executed on database events • Before or after: – Insert – Update – Delete – Undelete
  • 44. Before or After? • Before – Update or validate values before they are saved to the database – Example: Prevent double-booking of a speaker • After – Need access to values set by the database (Id, lastUpdated, …) – Example: Send speaker confirmation email
  • 45. Bulk Mode • Trigger API is designed to support bulk operations – Data Import, Bulk API, etc. • Triggers work on bulk of records, not single records • Context variables provide access to data: – Trigger.old and Trigger.new (List) – Trigger.oldMap and Trigger.newMap (Map)
  • 46. Example 1 trigger WelcomeKit on Account (after insert) { List<Case> myCases = new List<Case>(); for (Account account : Trigger.new) { Case welcomeCase = new Case(); welcomeCase.Subject = 'Mail Welcome Kit'; welcomeCase.AccountId = account.Id; myCases.add(welcomeCase); } insert myCases; }
  • 47. Example 2 Trigger on Account (before update) { for (Account acc: Trigger.New) { // Compare new value with old value if (acc.Rating != Trigger.oldMap.get(acc.Id).Rating) { // Your Logic } } }
  • 48. Workflow vs Trigger Workflow Trigger Created with Clicks Code What can it do • Update field • Send email • Create task • Send outbound message • Launch flow (flow trigger) ~ Anything (e.g. create/delete records, REST callout, etc.) Cross-object field updates Limited (detail -> master) Any
  • 49. Lab 6: Writing Triggers • Write the SendConfirmationEmail trigger • Write the RejectDoubleBooking trigger
  • 51. What's a Visualforce Page? • HTML page with tags executed at the server-side to generate dynamic content • Similar to JSP and ASP • Can leverage JavaScript and CSS libraries • The View in MVC architecture
  • 52. Model-View-Controller Model Data + Rules Controller View-Model interactions View UI code  Separation of concerns – No data access code in view – No view code in controller  Benefits – Minimize impact of changes – More reusable components
  • 53. Model-View-Controller in Salesforce View • Metadata • Standard Pages • Visualforce Pages • External apps Controller • Metadata • Standard Controllers • Controller Extensions • Custom Controllers Model • Metadata • Objects • Triggers (Apex) • Classes (Apex)
  • 54. Expression Language • Anything inside of {! } is evaluated as an expression – Dynamic variables: {!Contact.Phone} or {!myApexVariable} – Logic: {! IF (Opportunity.Stage == ‘Closed/Won’, val_if_true, val_if_false)} – Functions: {!JSENCODE(Account.BillingAddress)} • Same expression language as Formulas • $ provides access to global variables (User, Page, RemoteAction, Resource, …) – {! $User.FirstName } {! $User.LastName }
  • 55. Example 1 <apex:page> <h1>Hello, {!$User.FirstName}</h1> </apex:page>
  • 56. Example 2 <apex:page standardController="Contact"> <apex:form> Standard controller object <apex:inputField value="{!contact.firstname}"/> <apex:inputField value="{!contact.lastname}"/> <apex:commandButton action="{!save}" value="Save"/> </apex:form> </apex:page> Function in standard controller
  • 57. Standard Controller • A standard controller is available for all objects – You don't have to write it! – No test methods needed – Can grab a single record or set of records • Provides standard CRUD operations – Create, Update, Delete, Field Access, etc. • Can be extended with more capabilities (next module) • Uses id query string parameter in URL to access object
  • 58. Component Library • Presentation tags – <apex:pageBlock title="My Account Contacts"> • Fine grained data tags – <apex:outputField value="{!contact.firstname}"> – <apex:inputField value="{!contact.firstname}"> • Coarse grained data tags – <apex:detail> – <apex:pageBlockTable> • Action tags – <apex:commandButton action="{!save}" >
  • 59. Demo: Dissect a Visualforce Page & Build with Bootstrap
  • 60. Email Templates Embedded in Page Layouts Generate PDFs Custom Tabs Mobile Interfaces Page Overrides Where can I use Visualforce?
  • 61. Lab 7: Writing Visualforce Pages • Write the SpeakerForm Visualforce page • Set it as default for creating and editing speakers
  • 62. Writing Controller Extensions and Custom Controllers
  • 63. What's a Controller Extension? • Custom class written in Apex • Works on the same object as the standard controller • Can override standard controller behavior • Can add new capabilities
  • 64. Defining a Controller Extension <apex:page standardController="Speaker__c" extensions="SpeakerCtrlExt, ext2"> Provides basic CRUD Overrides standard actions and/or provide additional capabilities
  • 65. Anatomy of a Controller Extension public class SpeakerCtrlExt { private final Speaker__c speaker; private ApexPages.StandardController stdController; public SpeakerCtrlExt (ApexPages.StandardController ctrl) { this.stdController = ctrl; this.speaker = (Speaker__c)ctrl.getRecord(); } // method overrides // custom methods }
  • 66. Demo: Dissect a Controller Extension
  • 67. What's a Custom Controller? • Custom class written in Apex • Doesn't work on a specific object • Provides custom data • Provides custom behaviors
  • 68. Defining a Custom Controller <apex:page controller="FlickrController">
  • 69. Custom Controller Example public with sharing class FlickrController { public FlickrList getPictures() { HttpRequest req = new HttpRequest(); req.setMethod('GET'); req.setEndpoint('http://api.flickr.com/services/feeds/'); HTTP http = new HTTP(); HTTPResponse res = http.send(req); return (FlickrList) JSON.deserialize(res.getBody(), FlickrList.class); } }
  • 70. Lab 8: Writing a Controller Extension • Write a Controller Extension that supports Picture Upload
  • 71. Samantha Ready Senior Developer Evangelist @samantha_ready Survey bit.ly/df-how-introforce
  • 73. Certification Logos for “Speaker Intro Slides” For salesforce.com use only Guides for logo placement
  • 74. Example of a Table Table subtitle Column title Column title Column title Column title 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
  • 75. Example of a Table Table style and coloring Column title Column title Column title Column title 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

Editor's Notes

  • #3: What we’re going to do today Who this class was intended for
  • #7: Cover the agenda only as the use case will be described in a later slide.
  • #8: Access online workbook here
  • #9: Our platform is not merely a cloud hosting service, it is a series of tools and features that enable developers to be successful. On our platform, as you building your data model – you are getting a lot more than just a relational database. You get a mobile app, right out of the gate.
  • #10: While Salesforce is often thought of as a CRM company, it is actually so much more than that. The platform encompasses our 3 core platform services: Force.com, for building web apps natively on top of Salesforce with a direct line of access into your data. Heroku for building public, consumer applications in any language. And Exact Target with a suite of advanced marketing and automation tools. On top of that we have all of our core platform APIs to extend and integrate your applications however you requirements demand, and the Salesforce1 mobile app that gives you an instant mobile solution for your internal organization.
  • #13: We’re going to go through adding in programmatic functionality to an installed schema for a conference management app. This demo app manages a conference in a similar way to how we run Dreamforce—objects for sessions, speakers, and automation for session management.
  • #14: They should create a brand new DE org if they have not done so recently. They should not use a Trial, Sandbox or Production org. Emphasize our DE orgs are free and do not expire (they are not product trials)
  • #19: Poll the audience about their experience level with Apex before walking through this slide so you know how deep you need to talk about it Points that could be called out: Public class – what it means, could be public with sharing (and what that means) Variable declaration (public, data type, instance variable name) and a getter (allows your VF page to get this value to display it) and a setter (allows your VF page to set the value from a form) Method Similar syntax to Java, right? The only thing missing from this sample is a constructor which is optional for being able to initialize values
  • #20: You have a lot of options for development environments… The Developer Console is a comprehensive suite of developer tools that is included with your DE and doesn’t require any software downloads. There are also a lot of open source projects that exist with a great set of tools like the Force.com IDE on eclipse or the MavensMate plugin for Sublime… If you prefer to use the command line, the Force CLI has a lot of helpful tools for being able the import/export data and do migrations from a command line
  • #21: For the exercises today we’re going to use the Developer Console…
  • #22: For our first hands on exercise we’re going to need to install the custom schema package which will include all of the custom objects for our conference management app. We’re going to create an email manager class and execute that Apex anonymously to see how it works.
  • #25: Lets walk through the anatomy of a SOQL statement… This is the most basic form of a SOQL statement and you can see it looks a lot like SQL. You query for a set of records, specify which fields you want to grab values for, and then specify the Salesforce object that you’re trying to query
  • #26: But SOQL has limits, and will throw an error if you are trying to query too big of a data set. You can start narrowing down the result set by adding a WHERE clause
  • #27: The WHERE clause can be a concatenation of multiple logical expressions, like in this case where we are looing for a contact who has a defined phone number and the name is like the string ‘rose’. The percent symbols before and after is like placing a wildcard where text could come before or after rose. Melrose and Roselyn would both fit into this category.
  • #28: Lists in Salesforce can be ordered and indexed, so you can specify how you would like to order it right from within the query
  • #29: And again, coming back to limits. You can specify a limit on your records returned.
  • #30: You can also query for fields on the parent object through a relationship field. If this were a custom object you were traversing, like Session__c for example, you would need to use Session__r.FieldName to traverse through the relationship field to grab the parent’s field values.
  • #46: Best practice for triggers is to BULKIFY! Best practice: don’t do SOQL statements or DML operations inside of a for loop Work with collections of data in lists, sets, or maps and limit API calls
  • #47: Walk through building this trigger Why is it afgter insert? Loops through a potential single to large set of records depending on whether or not it was a data load of multiple records Trigger.new Bulkified! Insert outside of the for loop
  • #48: Why is it before? (you don’t want to go into an infinite loop modifying an account and if you want to compare against an old value, you need to use a before trigger for access to the oldMap
  • #53: When building custom pages, Visualforce uses the MVC design pattern which is the most commonly used design paradigm in all of enterprise computing. It allows you to tackle each facet of the application development separately, while allowing each member to interoperate
  • #54: you’ll notice metadata is in the model, view, and controller. This is because the platform creates, abides by, and uses the rich metadata attached to every object and programmatic component. To start at the base, or your model, this is your data and configurations around those objects. When coding on Force.com, in order to pull that data onto a web page for an end user to view, you need a controller to control your view-model interaction. These will also control how the page works, and how it interacts again with the database and could be a standard controller (no apex) or a custom controller or controller extension (apex). Finally, to build a view, you can create a Visualforce page when the standard page layout doesn’t meet your needs.
  • #56: Simplest VF page Always has a page tag as the first/last line This uses a global user instance variable to grab the logged in users info
  • #57: Standard controller can be both a standard object and a custom object All inputs an actions must happen within a form tag The save method uses the standard controller to create/save a contact If there were a contact Id in the url, the page would know to pre-populate the inputs with the appropriate field values to be saved/updated
  • #60: Yelp page Twitter bootstrap and visualforce: https://developer.salesforce.com/blogs/developer-relations/2014/03/twitter-bootstrap-and-visualforce-in-minutes.html
  • #66: The main thing to call out here is the parameter for the standard controller in the constructor Also call out how it assigns the standard controller to an ApexPages.StandardController variable that can be used throughout the entire class Also, to use the individual record grabbed by the standard controller through the Id field in the URL that accessed the page, you need to caste the Sobject type to the standardController object type
  • #70: The main purpose of this class is just to show that the controller has totally custom functionality, and when you don’t have another standard or custom controller and this is the primary (and solo) controller, you no longer are required to have a constructor