3. 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 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, 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, 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-K for the most recent fiscal quarter ended July 31, 2011. This document and others 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 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.
4. Login and get ready
UofM Wireless
Internet Instructions
On Each Table
9. Salesforce is a Platform Company. Period.
-Alex Williams, TechCrunch
500M
API Calls Per Day6B
Lines of Apex
4M+
Apps Built on
the Platform
72B
Records Stored
Salesforce1 Platform
12. Every Object, Every Field: Salesforce1 Mobile Accessible
AppExchange Apps:
Dropbox Concur Evernote ServiceMax More
Custom Apps and Integrations:
SAP Oracle Everything Custom More
Sales, Service and Marketing
Accounts Cases Campaigns Dashboards More
14. Every Object, Every Field: Apex and Visualforce Enabled
Visualforce Pages
Visualforce Components
Apex Controllers
Apex Triggers
Custom UICustom UI
Custom LogicCustom Logic
15.
16. Warehouse Application Requirements
• Track price and inventory on hand for all merchandise
• Create invoices containing one or more merchandise items
as a line items
• Present total invoice amount and current shipping status
17. Warehouse Data Model
Merchandise
Name Price Inventory
Pinot $20 15
Cabernet $30 10
Malbec $20 20
Zinfandel $10 50
Invoice
Number Status Count Total
INV-01 Shipped 16 $370
INV-02 New 20 $200
Invoice Line Items
Invoice Line Merchandise Units
Sold
Unit Price Value
INV-01 1 Pinot 1 15 $20
INV-01 2 Cabernet 5 10 $150
INV-01 3 Malbec 10 20 $200
INV-02 1 Pinot 20 50 $200
18. Indexed Field
• Primary Keys
• Id
• Name
• OwnerId
• Audit Dates
• Created Date
• Last Modified Date
• Foreign Keys
• Lookups
• Master-Detail
• CreatedBy
• External ID Fields
• External ID Fields
• Unique Fields
• Fields indexed by Salesforce
Using a query with two or more indexed filters greatly increases performance
19. Two Approaches to Development
Visualforce Pages
Visualforce Components
Apex Controllers
Apex Triggers
Metadata API
REST API
Bulk API
Formula Fields
Validation Rules
Workflows and Approvals
Custom Objects
Custom Fields
Relationships
Page Layouts
Record Types
User
Interface
Business
Logic
Data
Model
Declarative Approach Programmatic Approach
20. Declarative before Programmatic
Use declarative features when possible:
• Quicker to build
• Easier to maintain and debug
• Possible addition of new features
• Do not count against governor limits
For example:
• Will a workflow suffice instead of a trigger?
• Will a custom layout work instead of Visualforce?
21. Warehouse Data Model
Merchandise
Name Price Inventory
Pinot $20 15
Cabernet $30 10
Malbec $20 20
Zinfandel $10 50
Invoice
Number Status Count Total
INV-01 Shipped 16 $370
INV-02 New 20 $200
Invoice Line Items
Invoice Line Merchandise Units
Sold
Unit Price Value
INV-01 1 Pinot 1 20 $20
INV-01 2 Cabernet 5 10 $150
INV-01 3 Malbec 10 20 $200
INV-02 1 Pinot 20 50 $200
Workflow Rule
When inserted, if unit price is blank then fill it with
the Merchandise price value
24. Introduction to Apex
• Object-Oriented Language
• Dot Notation Syntax
• Cloud based compiling, debugging and unit testing
• “First Class” Citizen on the Platform
25. public with sharing class myControllerExtension implements Util {
private final Account acct;
public Contact newContact {get; set;}
public myControllerExtension(ApexPages.StandardController stdController) {
this.acct = (Account)stdController.getRecord();
}
public PageReference associateNewContact(Id cid) {
newContact = [SELECT Id, Account from Contact WHERE Id =: cid LIMIT 1];
newContact.Account = acct;
update newContact;
}
}
Apex Anatomy
Class and Interface based Scoped Variables Inline SOQL Inline DML
26. Developer Console
• Browser Based IDE
• Create and Edit Classes
• Create and Edit Triggers
• Run Unit Tests
• Review Debug Logs
27. Hands On Tutorials
#2: Using the Dev Console
#3: Creating Apex Classes
Extra Credit:
http://bit.ly/ELEVATE-Apex-Email-EC
29. • Code to test code
• Tests can mirror user
expecations
• System Asserts increase
predictability
• Line Coverage increase
predictability
Unit Testing
30. Unit Testing in Apex
Built in support for testing
– Test Utility Class Annotation
– Test Method Annotation
– Test Data build up and tear down
Unit test coverage is required
– Must have at least 75% of code covered
Why is it required?
31. Basic Unit Test Structure
@isTest
public class TestClase{
@isTest static void testCase(){
//setup test data
List<Contact> contacts = ContactFactory.createTestContacts();
//process / perform logic
EvaluateContacts.process(contacts);
//assert outcome
System.assertEquals(EvaluateContacts.processed.size(),contacts.size());
}
}
32. Testing Permissions
//Set up user
User u1 = [SELECT Id FROM User WHERE Alias='auser'];
//Run As U1
System.RunAs(u1){
//do stuff only u1 can do
}
34. Testing Context and Asynchronous Behavior
// this is where the context of your test begins
Test.StartTest();
//execute future calls, batch apex, scheduled apex
UtilityRESTClass.performCallout();
// this is where the context ends
Text.StopTest();
System.assertEquals(a,b); //now begin assertions
35. Apex Triggers
• Event Based Logic
• Associated with Object Types
• Before or After:
• Insert
• Update
• Delete
• Undelete
36. Controlling Flow
trigger LineItemTrigger on Line_Item__c
(before insert, before update) {
//separate before and after
if(Trigger.isBefore) {
//separate events
if(Trigger.isInsert) {
System.debug(‘BEFORE INSERT’);
DelegateClass.performLogic(Trigger.new);
37. Static Flags
public with sharing class AccUpdatesControl {
// This class is used to set flag to prevent multiple calls
public static boolean calledOnce = false;
public static boolean ProdUpdateTrigger = false;
}
38. Chatter Triggers
trigger AddRegexTrigger on Blacklisted_Word__c (before insert, before update)
{
for (Blacklisted_Word__c f : trigger.new)
{
if(f.Custom_Expression__c != NULL)
{
f.Word__c = '';
f.Match_Whole_Words_Only__c = false;
f.RegexValue__c = f.Custom_Expression__c;
}
}
}
39. Hands On Tutorials
#4: Apex Triggers
#5: Apex Unit Tests
Extra Credit: http://bit.ly/ELEV-triggers
http://bit.ly/ELEVATE-Mock-Endpoint-EC
45. Apex Batch Processing
Governor Limits
– Various limitations around resource usage
Asynchronous processing
– Send your job to a queue and we promise to run it
Can be scheduled to run later
– Kind of like a cron job
46. Batchable Interface
global with sharing class WHUtil implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{ //Start on next context }
global void execute(Database.BatchableContext BC,
List<sObject>scope)
{ //Execute on current scope }
global void finish(Database.BatchableContext BC)
{ //Finish and clean up context }
}
47. Unit Testing Asynchronous Apex
//setup test data
Test.StartTest();
System.schedule('testSchedule','0 0 13 * * ?',new,WarehouseUtil());
ID batchprocessid = Database.executeBatch(new WarehouseUtil());
Test.StopTest();
//assert outcomes
49. Apex HTTP
public FlickrList getFlickrData(string tag) {
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint('http://api.flickr.com/services/feeds/photos_public.gne?
nojsoncallback=1&format=json&tags='+tag);
HTTP http = new HTTP();
HTTPResponse res = http.send(req);
return
(FlickrList)JSON.deserialize(res.getBody().replace(''',''),FlickrList.class
);
}
50. Apex REST
@RestResource(urlMapping='/CaseManagement/v1/*')
global with sharing class CaseMgmtService
{
@HttpPost
global static String attachPic(){
RestRequest req = RestContext.request;
RestResponse res = Restcontext.response;
Id caseId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Blob picture = req.requestBody;
Attachment a = new Attachment (ParentId = caseId,
Body = picture,
ContentType = 'image/
51. Unit Tests: Mock HTTP Endpoints
@isTest
global class MockHttp implements HttpCalloutMock {
global HTTPResponse respond(HTTPRequest req) {
// Create a fake response
HttpResponse res = new HttpResponse();
res.setHeader('Content-Type', 'application/json');
res.setBody('{"foo":"bar"}');
res.setStatusCode(200);
return res;
}
}
52. Unit Tests: Mock HTTP Endpoints
@isTest
private class CalloutClassTest {
static void testCallout() {
Test.setMock(HttpCalloutMock.class, new MockHttp());
HttpResponse res = CalloutClass.getInfoFromExternalService();
// Verify response received contains fake values
String actualValue = res.getBody();
String expectedValue = '{"foo":"bar"}';
System.assertEquals(actualValue, expectedValue);
}
}
53. Hands On Tutorials
#6: Apex Batch Processing
#7: Apex REST
Extra Credit:
http://bit.ly/ELEVATE-REST-Response-EC
57. Apex Forms
– Visualforce component bound to an Apex Method
Javascript Remoting
– Annotated Apex methods exposed to JavaScript
Interacting with Apex
65. How Canvas Works
• Only has to be accessible from the
user’s browser
• Authentication via OAuth or Signed
Response
• JavaScript based SDK can be
associated with any language
• Within Canvas, the App can make
API calls as the current user
• apex:CanvasApp allows
embedding via Visualforce
Any Language, Any Platform
74. Developer Groups
Join a Salesforce Developer Group
http://bit.ly/fdc-dugs
Twin Cities Developer Group
http://www.meetup.com/SFTCDUG/
Become a User Group Leader
Email: April Nassi <anassi@salesforce.com>
The recommended agenda can be found here:
https://docs.google.com/a/salesforce.com/spreadsheet/ccc?key=0Akr6pvkAv8X5dGFEN2ZWNUxWbS1SVFBoRS1oZU5kQWc&usp=drive_web#gid=22
Under the “Workshop: S1 Programmer” tab
Errors, comments, suggestions in either the deck or the workbook can be mentioned on Josh Birk’s Chatter feed, or written up in Google Docs and shared with Josh Birk and Mario Korf.
There is a demo org for the Warehouse ELEVATE here:
https://login.salesforce.com/?un=elevate@demo.com&pw=demo1234
It has:
Enhanced Data Model
The workflows, etc from the Basic class
The Apex and VF from the Programmers class
Canvas definitions from the Programmers class
- including the Create_Delivery Invoice action
FlickrView (also known as PuppyForce)
Chatter Blacklist
BEFORE YOU PRESENT – go through the slides and update:
YOUR NAME(S)
TWITTER/EMAIL
LUNCH INFO
BITLY SURVEY LINK
DUG INFORMATION
As these are just placeholders in the slides right now.
THESE SPEAKER NOTES ARE NOT VERBATIM. They are there just as hints as to what to cover.
Introduce the day. Poll the audience for level of experience. You’ll want to know who is a Java dev and who is a new or experienced to our platform.
Introduce Yourselves
Note: this is a slide if there is more than one presenter
Introduce Yourselves
Note: this is a slide if there is only one presenter
Introduce Yourselves
Note: this is a slide if there is more than one presenter
Safe Harbor
Change this slide to match the local internet requirements.
Highlight that this is not just a day of talking to them, this is a dialogue and they should ask questions as they like – even ones that don’t pertain to the current “section”. Projects they’re working on, features they have heard about, etc.
Since there may be experienced devs, invite the to use the IDE of their choice (Sublime, Eclipse) even if the tutorials point to Dev Console
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)
THIS IS THE ONLINE VERSION OF THE NEW WORKBOOK DRAFT
Salesforce is often thought of as a CRM company, but these stats show we have platform services in use as well
1.4 million includes Force.com, Heroku and ExactTarget
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.
You get our API’s, automatically extended: REST, SOAP, Bulk, Streaming
And our programmatic features are automatically aware of the data model as well.
Now some of you might have worked with out Warehouse demo application before. If you haven’t here’s a quick recap.
These are the core business requirements of the Warehouse application
Here is an overview of what our data model will look like.
POTENTIAL DEMO: View this in Schema Builder
This is our first “pro tip” slide. Using these kinds of fields can increase SOQL searches.
Our Basics workshop covers the declarative side of our platform, but let’s do a quick review.
Here is an overview of what our data model will look like.
POTENTIAL DEMO: View this in Schema Builder
OK, this is a quick break to make sure everyone is up and running. The workbook walks through installing the warehouse model, creating some test data and basically making sure your DE org is setup correctly. Let’s take a chance to do that.
For when declarative logic is not enough, we provide Apex. Apex is a cloud-based programming language, very similar to Java – except that you can code, compile and deploy all right from your Salesforce instance. You’ll see how we can create robust programmatic functions right from your browser.
If you are familiar with Java or C#, you are going to be familiar with Apex. It is OO and uses dot notation. However, Apex is completely cloud based – you can compile and debug right in your browser. Because it runs right in your instance it is also a “first class” citizen – meaning we can do actions right within Apex without any additional configuration or libraries.
Let’s take a look at an example Apex class
That’s what Apex is – how do we code it? It is possible to use a third party IDE like Sublime or Eclipse – but you can also code right in your browser. Our Developer Console allows you to create and edit code, debug your applications and run unit tests.
POTENTIAL DEMO: Show Anonymous Apex in the Dev Console
This will be a quick review for the Force.com devs in the room.
That is a picture of the first ever bug. Yes, it was a real bug. To keep bugs from happening, we use unit testing.
Basic overview of how Unit Testing works
POTENTIAL DEMO: Walk through TestInvoiceStatementDeletion on the demo org and run the test
Basic overview of how Unit Testing works
POTENTIAL DEMO: Walk through TestInvoiceStatementDeletion on the demo org and run the test
Pro tip: You may want to have a unit test follow a scenario based on a specific profile. It’s pretty easy to do.
Pro tip: You may want to have a unit test follow a scenario based on a specific profile. It’s pretty easy to do.
Pro tip: You can also load your test data off a static resource, it is easier to handle large data sets and and test data can be swapped out easily.
Pro tip: You can also load your test data off a static resource, it is easier to handle large data sets and and test data can be swapped out easily.
Overview of Apex Triggers
Pro tip: Best to use on trigger per logic, and then you can control the flow of the logic with the system levelTrigger variable
Pro tip: Triggers retain scope during an execution, so if want to keep them from being hit again and again (based on other updates/workflows) you can use a static flag on the trigger to turn it “off”
Pro tip: We can use Triggers on Chatter. In fact:
Potential Demo: Chatter Blacklist
OK, now we have two tutorials. The first is building a simple trigger on the plaform and then there is a walkthrough of a unit test.
For the vets in the room, we’ve got a little extra credit challenge. This is in the form of a gist online, but it walks you through a more advanced version of a trigger.
Update this slide with specifics about lunch
Scheduled Apex allows us to run business logic in the background at specific intervals
It uses the Schedulable interface, which allows us define the execute method to control what logic will be run on the schedule
You can define the schedule in two ways
We also have Batch Apex, which is a close cousin to Scheduled Apex
Batch apex allows us to queue up data and have logic run against it asynchronously.
The interface itself allows us to introduce logic when a queue of objects is being run.
POTENTIAL DEMO: CleanUpRecords
PRO Tip: Remember when we talked about controlling context with Start and Stop test? This is also works for batch processing.
At the beginning we talked about how your data model is automatically extended with our API’s. So out of the box, no programming, you get REST and SOAP endpoints to query and manipulate data. Basic CRUD stuff. You also get our Bulk and Streaming API for free – but we don’t have time to cover those here.
You can also expose custom logic via endpoints using Apex.
We are going to focus on Apex REST today. This is how you setup an Apex REST class. The RestResource annotation defines the actual endpoint. Methods are then assigned an HTTP method. So when we hit the CaseManagement endpoint here, and we send it an HTTP Post request … it will hit the attachPic method.
Potential DEMO: Workbench operating against MerchandiseManager class
Pro Tip: In your unit test, you can fake a third party endpoint. You generate a class that will a mock a return.
Then you sub that endpoint for what the real code will hit when it attempts to call out.
OK, two more tutorials – the first on Batch processing and then another on Apex REST.
Visualforce is the user interface sibling to Apex. It also runs in the cloud, in your instance – and it allows you to create brand new experiences for your customers and users.
What do we mean by components? Well you’d start with a page component, and that will define how the whole page is going to be rendered. And then you can add things like a form and fields for the form. Now everything you see here will be HTML when it gets outputted. So you’d have and HTML form, HTML input tags, etc. To the browser, it is just standard HTML.
But how are we binding data here? We define a controller, which gets access to server-side logic. Whenever you see these brackets and that exclamation point, you’re looking at dynamically bound data which will effect how the component is rendered.
However, the server-side logic here is a little interesting.
POTENTIAL DEMO: Do Standard Controller demo, then go back to describe custom controllers and extensions.
However what we just saw there is using a viewstate. If you aren’t familiar with a viewstate, it’s a block of hashed information on the client which tracks changes – allowing us to get around the fact that HTTP is stateless.
We have options, though. While a lot of Visualforce relies on bound forms to transmit data (and a viewstate), we can also talk directly to Apex via JavaScript and avoid the viewstate. This is more JavaScript friendly and also has a small footprint.
We have options, though. While a lot of Visualforce relies on bound forms to transmit data (and a viewstate), we can also talk directly to Apex via JavaScript and avoid the viewstate. This is more JavaScript friendly and also has a small footprint.
DEMO: JS Remoting. You could preview FindNearby, or you could do a quick example on the fly.
The data is going to come back to us in JSON. Note that result here might be a string, or JSON representation of an array or object.
Or we’ll see an error
DEMO: JS Remoting
In Spring ’14 we are rolling out a preview of a new feature called Remote Objects. It lets us perform CRUD functionality without having to write an Apex class, kind of like a Standard Controller.
So a quick overview.
Now we have a tutorial on writing a Visualforce page. This page is designed to run in Salesforce1, and uses JavaScript Remoting to locate nearby warehouses.
Let’s talk about another kind of user interface. This is one you might already have built out, running on your own network. How can we best integrate that back into Salesforce?
Canvas makes that easy. With a connected app defined, Canvas handles the authentication of the current user against the third party UI. The external application can be anything the user would normally be able to see in their browser. It can then make API calls on the user’s behalf.
We have API’s to fit a wide range of use cases. Our REST API is very versatile, and one of the main use cases is mobile applications – and Canvas relies on the REST API to make calls back into Salesforce.
Before we can make a callout though, we need to authenticate right? Canvas makes this easy, and it uses two methods – but both are similar and based on the flow of OAuth. OAuth is used by Google, Facebook, Twitter, pretty much everyone on the planet to securely authenticate first party credentials with third party apps.
Let’s walk through the flow of OAuth.
Demo: A great one here could be Forcecraft
OK, this tutorial walks us through two different applications using Canvas.
Update this slide with local DUG information
THESE SLIDES ARE OPTIONAL DEPENDING ON TIME
For instance, we talked about how your data model automatically extends what VF and Apex can do – but what about our API’s? We have several.
THESE SLIDES ARE OPTIONAL DEPENDING ON TIME
Salesforce1 Mobile is one of our offerings, but you can also create your own custom applications.
POTENTIAL DEMO: Quick Start on forceios / forcedroid
THIS SLIDE MAY ALSO HAVE BEEN COVERED BY AN ISV SPEAKER
THESE SLIDES ARE OPTIONAL DEPENDING ON TIME
We also have an entire marketplace for finding, buying and selling apps.
NOTE: Chatter Blacklist as a Labs App (Free and Unmanaged)
THESE SLIDES ARE OPTIONAL DEPENDING ON TIME
Heroku provides a framework for easily deploying the applications in the language of your choice.
POTENTIAL DEMO: Quick PHP deployment.
Introduce Yourselves
Note: this is a slide if there is more than one presenter
Introduce Yourselves
Note: this is a slide if there is more than one presenter