Salesforce1 Platform
for Programmers
Hervé Maleville
Solution Engineer - Platform
@hmaleville
Herve.maleville@salesforce.com
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.
Be interactive
http://developer.force.com/join
Free Developer Environment
Online Workbook
http://bit.ly/force_apex_book
Salesforce is a Platform Company. Period.
-Alex Williams, TechCrunch
1B+
API Calls Per Day6B
Lines of Apex
4M+
Apps Built on
the Platform
72B
Records Stored
Salesforce1 Platform
1.4 million…and growing
Core
Services
Chatter
Multi-
language
Translation
Workbench
Email
ServicesAnalytics
Cloud
Database
Schema
Builder
Search
Visualforce
MonitoringMulti-tenant
Apex
Data-level
Security
Workflows
APIs
Mobile
Services
Social
APIs
Analytics
APIs
Bulk APIsRest APIs Metadata
APIs
Soap APIs
Private App
Exchange
Custom
Actions
Identity
Mobile
Notifications
Tooling
APIs
Mobile
Packs
Mobile SDK
Offline
Support
Streaming
APIs
Geolocation
ET 1:1 ET Fuel
Heroku1
Heroku
Add-Ons
Sharing
Model
ET API
Salesforce1 Platform
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
Your App
Every Object, Every Field: API Enabled
GET
POST
PATCH
DELETE
OAuth 2.0
HTTPS
Every Object, Every Field: Apex and Visualforce Enabled
Visualforce Pages
Visualforce Components
Apex Controllers
Apex Triggers
Custom UICustom UI
Custom LogicCustom Logic
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
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?
Apex
Cloud-based programming language on Salesforce1
Introduction to Apex
• Object-Oriented Language
• Dot Notation Syntax
• Cloud based compiling, debugging and unit
testing
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
Developer Console
• Browser Based IDE
• Create and Edit Classes
• Create and Edit Triggers
• Run Unit Tests
• Review Debug Logs
Unit Testing
Code which asserts that existing logic is operating correctly
• Code to test code
• Tests can mirror user
expectations
• System Asserts increase
predictability
• Line Coverage increase
predictability
Unit Testing
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?
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());
}
}
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
}
ProTip: Load Static Resource Data from CSV
List<Invoice__c> invoices = Test.loadData(Invoice__c.sObjectType, 'InvoiceData');
update invoices;
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
Test.StopTest();
System.assertEquals(a,b); //now begin assertions
Apex Triggers
• Event Based Logic
• Associated with Object Types
• Before or After:
• Insert
• Update
• Delete
• Undelete
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);
Scheduled Apex
Interface for scheduling Apex jobs
Schedulable Interface
global with sharing class WarehouseUtil implements Schedulable {
//General constructor
global WarehouseUtil() {}
//Scheduled execute
global void execute(SchedulableContext ctx) {
//Use static method for checking dated invoices
WarehouseUtil.checkForDatedInvoices();
}
}
System.schedule('testSchedule','0 0 13 * * ?',
new WarehouseUtil());Via Apex
Via Web UI
Schedulable Interface
Batch Apex
Apex interface for processing large datasets asynchronously
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
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 }
}
ProTip: 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
Apex Integration
Using Apex with third party systems
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
);
}
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/
ProTip: Unit Tests: Mock HTTP Endpoints
@isTest
global class MyMockHttp 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;
}
}
Unit Tests: Mock HTTP Endpoints
@isTest
private class CalloutClassTest {
static void testCallout() {
Test.setMock(HttpCalloutMock.class, new MyMockHttp());
HttpResponse res = CalloutClass.getInfoFromExternalService();
// Verify response received contains fake values
String actualValue = res.getBody();
String expectedValue = '{"foo":"bar"}';
System.assertEquals(actualValue, expectedValue);
}
}
Visualforce
Component-based user interface framework on Salesforce1
Visualforce Components
<apex:page StandardController="Contact” extensions="duplicateUtility”
action="{!checkPhone}”>
<apex:form>
<apex:outputField var="{!Contact.FirstName}” />
<apex:outputField var="{!Contact.LastName}" />
<apex:inputField var="{!Contact.Phone}" />
<apex:commandButton value="Update" action="{!quicksave}" />
</apex:form>
</apex:page>
Standard & Custom Controllers
Custom Extensions Data bound components Controller Callbacks
Hashed information block to track server side transports
Viewstate
 Apex Forms
– Visualforce component bound to an Apex Method
 Javascript Remoting
– Annotated Apex methods exposed to JavaScript
Interacting with Apex
Using JavaScript Remoting
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.ContactExtension.makeContact}',
“003i000000cxdHP”, “Barr”
function(result, event) {
//...callback to handle result
alert(result.LastName);
});
@RemoteAction
global static Contact makeContact
(String cid, String lname) {
return new Contact(id=cid,Last_Name=lname);
}
ApexVisualforce
Sample Success Message
{
"statusCode":200,
"type":"rpc",
"ref":false,
"action":"IncidentReport",
"method":"createIncidentReport",
"result":"a072000000pt1ZLAAY",
"status":true
}
Sample Error Message
{
"statusCode":400,
"type":"exception",
"action":"IncidentReport",
"method":"createIncidentReport",
"message":"List has more than 1 row for assignment to SObject",
"data": {"0":{"Merchandise__c":"a052000000GUgYgAAL",
"Type__c":"Accident",
"Description__c":"This is an accident report"}},
"result":null,
"status":false
}
Remote Objects
<apex:jsSObjectBase shortcut="tickets">
<apex:jsSObjectModel name="Ticket__c" />
<apex:jsSObjectModel name="Contact" fields="Email" />
<script>
var contact = new tickets.Contact();
contact.retrieve({
where: {
Email: {
like: query + '%'
}
}
}, function(err, data) {
//handle query results here
CRUD/Q Functionality Data Model Components JavaScript Framework Friendly
Summary: Interacting with Apex
• ActionFunction allows direct binding of variables
• ActionFunction requires ViewState
• JavaScript Remoting binds to static methods
• JavaScript Remoting uses no ViewState
• Transient, Private and Static reduce Viewstate
Canvas
Framework for embedding third party apps into Salesforce
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
Using publisher.js
Sfdc.canvas.publisher.subscribe({
name: "publisher.post",
onData: function(e) {
// fires when the user hits 'Submit'
postToFeed();
}
});
Sfdc.canvas.publisher.publish({
name: "publisher.close",
payload: { refresh:"true"}
});
API Leveraging industry standard HTTP
REST API
OAuth
Industry standard for authenticating users for third party apps
Double-click to enter title
Double-click to enter text
The Wrap Up
Double-click to enter title
Double-click to enter text
http://developer.force.com
LUNCHMobile SDK
Development Kit for building hybrid and native iOS and Android apps
LUNCHAppExchange
Enterprise marketplace for Salesforce1 Apps
LUNCHHeroku
Polyglot framework for hosting applications
developer.salesforce.com/
Salesforce World Tour - Paris 2015
Le 25 Juin, 2015
Paris Porte de Versailles
Rejoignez l’Espace Développeurs
www.salesforce.com/paris
Démos de la Plateforme
Salesforce
Quick Start et Mini Hack avec
Salesforce1 Lightning
Théâtre des
développeurs
Librairie technique
Hervé Maleville
Platform Solution Engineer
@hmaleville
Herve.maleville@salesforce.co
m
Thank You

Salesforce1 Platform for programmers

  • 1.
  • 2.
    Hervé Maleville Solution Engineer- Platform @hmaleville Herve.maleville@salesforce.com
  • 3.
    Safe Harbor Safe harborstatement 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.
  • 5.
  • 6.
  • 7.
    Salesforce is aPlatform Company. Period. -Alex Williams, TechCrunch 1B+ API Calls Per Day6B Lines of Apex 4M+ Apps Built on the Platform 72B Records Stored Salesforce1 Platform
  • 8.
  • 9.
    Core Services Chatter Multi- language Translation Workbench Email ServicesAnalytics Cloud Database Schema Builder Search Visualforce MonitoringMulti-tenant Apex Data-level Security Workflows APIs Mobile Services Social APIs Analytics APIs Bulk APIsRest APIsMetadata APIs Soap APIs Private App Exchange Custom Actions Identity Mobile Notifications Tooling APIs Mobile Packs Mobile SDK Offline Support Streaming APIs Geolocation ET 1:1 ET Fuel Heroku1 Heroku Add-Ons Sharing Model ET API Salesforce1 Platform
  • 10.
    Every Object, EveryField: 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
  • 11.
    Your App Every Object,Every Field: API Enabled GET POST PATCH DELETE OAuth 2.0 HTTPS
  • 12.
    Every Object, EveryField: Apex and Visualforce Enabled Visualforce Pages Visualforce Components Apex Controllers Apex Triggers Custom UICustom UI Custom LogicCustom Logic
  • 13.
    Two Approaches toDevelopment 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
  • 14.
    Declarative before Programmatic Usedeclarative 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?
  • 15.
  • 16.
    Introduction to Apex •Object-Oriented Language • Dot Notation Syntax • Cloud based compiling, debugging and unit testing
  • 17.
    public with sharingclass 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
  • 18.
    Developer Console • BrowserBased IDE • Create and Edit Classes • Create and Edit Triggers • Run Unit Tests • Review Debug Logs
  • 19.
    Unit Testing Code whichasserts that existing logic is operating correctly
  • 20.
    • Code totest code • Tests can mirror user expectations • System Asserts increase predictability • Line Coverage increase predictability Unit Testing
  • 21.
    Unit Testing inApex  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?
  • 22.
    Basic Unit TestStructure @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()); } }
  • 23.
    Testing Permissions //Set upuser User u1 = [SELECT Id FROM User WHERE Alias='auser']; //Run As U1 System.RunAs(u1){ //do stuff only u1 can do }
  • 24.
    ProTip: Load StaticResource Data from CSV List<Invoice__c> invoices = Test.loadData(Invoice__c.sObjectType, 'InvoiceData'); update invoices;
  • 25.
    Testing Context andAsynchronous 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 Test.StopTest(); System.assertEquals(a,b); //now begin assertions
  • 26.
    Apex Triggers • EventBased Logic • Associated with Object Types • Before or After: • Insert • Update • Delete • Undelete
  • 27.
    Controlling Flow trigger LineItemTriggeron 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);
  • 28.
    Scheduled Apex Interface forscheduling Apex jobs
  • 29.
    Schedulable Interface global withsharing class WarehouseUtil implements Schedulable { //General constructor global WarehouseUtil() {} //Scheduled execute global void execute(SchedulableContext ctx) { //Use static method for checking dated invoices WarehouseUtil.checkForDatedInvoices(); } }
  • 30.
    System.schedule('testSchedule','0 0 13* * ?', new WarehouseUtil());Via Apex Via Web UI Schedulable Interface
  • 31.
    Batch Apex Apex interfacefor processing large datasets asynchronously
  • 32.
    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
  • 33.
    Batchable Interface global withsharing 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 } }
  • 34.
    ProTip: Unit TestingAsynchronous Apex //setup test data Test.StartTest(); System.schedule('testSchedule','0 0 13 * * ?',new WarehouseUtil()); ID batchprocessid = Database.executeBatch(new WarehouseUtil()); Test.StopTest(); //assert outcomes
  • 35.
    Apex Integration Using Apexwith third party systems
  • 36.
    Apex HTTP public FlickrListgetFlickrData(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 ); }
  • 37.
    Apex REST @RestResource(urlMapping='/CaseManagement/v1/*') global withsharing 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/
  • 38.
    ProTip: Unit Tests:Mock HTTP Endpoints @isTest global class MyMockHttp 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; } }
  • 39.
    Unit Tests: MockHTTP Endpoints @isTest private class CalloutClassTest { static void testCallout() { Test.setMock(HttpCalloutMock.class, new MyMockHttp()); HttpResponse res = CalloutClass.getInfoFromExternalService(); // Verify response received contains fake values String actualValue = res.getBody(); String expectedValue = '{"foo":"bar"}'; System.assertEquals(actualValue, expectedValue); } }
  • 40.
  • 41.
    Visualforce Components <apex:page StandardController="Contact”extensions="duplicateUtility” action="{!checkPhone}”> <apex:form> <apex:outputField var="{!Contact.FirstName}” /> <apex:outputField var="{!Contact.LastName}" /> <apex:inputField var="{!Contact.Phone}" /> <apex:commandButton value="Update" action="{!quicksave}" /> </apex:form> </apex:page> Standard & Custom Controllers Custom Extensions Data bound components Controller Callbacks
  • 42.
    Hashed information blockto track server side transports Viewstate
  • 43.
     Apex Forms –Visualforce component bound to an Apex Method  Javascript Remoting – Annotated Apex methods exposed to JavaScript Interacting with Apex
  • 44.
    Using JavaScript Remoting Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.ContactExtension.makeContact}', “003i000000cxdHP”,“Barr” function(result, event) { //...callback to handle result alert(result.LastName); }); @RemoteAction global static Contact makeContact (String cid, String lname) { return new Contact(id=cid,Last_Name=lname); } ApexVisualforce
  • 45.
  • 46.
    Sample Error Message { "statusCode":400, "type":"exception", "action":"IncidentReport", "method":"createIncidentReport", "message":"Listhas more than 1 row for assignment to SObject", "data": {"0":{"Merchandise__c":"a052000000GUgYgAAL", "Type__c":"Accident", "Description__c":"This is an accident report"}}, "result":null, "status":false }
  • 47.
    Remote Objects <apex:jsSObjectBase shortcut="tickets"> <apex:jsSObjectModelname="Ticket__c" /> <apex:jsSObjectModel name="Contact" fields="Email" /> <script> var contact = new tickets.Contact(); contact.retrieve({ where: { Email: { like: query + '%' } } }, function(err, data) { //handle query results here CRUD/Q Functionality Data Model Components JavaScript Framework Friendly
  • 48.
    Summary: Interacting withApex • ActionFunction allows direct binding of variables • ActionFunction requires ViewState • JavaScript Remoting binds to static methods • JavaScript Remoting uses no ViewState • Transient, Private and Static reduce Viewstate
  • 49.
    Canvas Framework for embeddingthird party apps into Salesforce
  • 50.
    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
  • 51.
    Using publisher.js Sfdc.canvas.publisher.subscribe({ name: "publisher.post", onData:function(e) { // fires when the user hits 'Submit' postToFeed(); } }); Sfdc.canvas.publisher.publish({ name: "publisher.close", payload: { refresh:"true"} });
  • 52.
    API Leveraging industrystandard HTTP REST API
  • 53.
    OAuth Industry standard forauthenticating users for third party apps
  • 54.
    Double-click to entertitle Double-click to enter text The Wrap Up
  • 55.
    Double-click to entertitle Double-click to enter text http://developer.force.com
  • 56.
    LUNCHMobile SDK Development Kitfor building hybrid and native iOS and Android apps
  • 57.
  • 58.
  • 59.
  • 60.
    Salesforce World Tour- Paris 2015 Le 25 Juin, 2015 Paris Porte de Versailles Rejoignez l’Espace Développeurs www.salesforce.com/paris Démos de la Plateforme Salesforce Quick Start et Mini Hack avec Salesforce1 Lightning Théâtre des développeurs Librairie technique
  • 61.
    Hervé Maleville Platform SolutionEngineer @hmaleville Herve.maleville@salesforce.co m Thank You

Editor's Notes

  • #2 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.
  • #3 Introduce Yourselves Note: this is a slide if there is only one presenter
  • #4 Safe Harbor
  • #5 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.
  • #6 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)
  • #7 THIS IS THE ONLINE VERSION OF THE NEW WORKBOOK DRAFT
  • #8 Salesforce is often thought of as a CRM company, but these stats show we have platform services in use as well 2 Billion Transactions a Day on 7/22.
  • #9 1.4 million includes Force.com, Heroku and ExactTarget
  • #10 Our platform is not merely a cloud hosting service, it is a series of tools and features that enable developers to be successful.
  • #11 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.
  • #12 You get our API’s, automatically extended: REST, SOAP, Bulk, Streaming
  • #13 And our programmatic features are automatically aware of the data model as well.
  • #14 Our Basics workshop covers the declarative side of our platform, but let’s do a quick review.
  • #16 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.
  • #17 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.
  • #18 Let’s take a look at an example Apex class
  • #19 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
  • #20 That is a picture of the first ever bug. Yes, it was a real bug. To keep bugs from happening, we use unit testing.
  • #21 Basic overview of how Unit Testing works POTENTIAL DEMO: Walk through TestInvoiceStatementDeletion on the demo org and run the test
  • #22 Basic overview of how Unit Testing works POTENTIAL DEMO: Walk through TestInvoiceStatementDeletion on the demo org and run the test
  • #23 Pro tip: You may want to have a unit test follow a scenario based on a specific profile. It’s pretty easy to do.
  • #24 Pro tip: You may want to have a unit test follow a scenario based on a specific profile. It’s pretty easy to do.
  • #25 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.
  • #27 Overview of Apex Triggers
  • #28 Pro tip: Best to use on trigger per logic, and then you can control the flow of the logic with the system level Trigger variable
  • #29 Scheduled Apex allows us to run business logic in the background at specific intervals
  • #30 It uses the Schedulable interface, which allows us define the execute method to control what logic will be run on the schedule
  • #31 You can define the schedule in two ways If you schedule via Apex, including via Execute Anonymous, you can schedule hourly.
  • #32 We also have Batch Apex, which is a close cousin to Scheduled Apex
  • #33 Batch apex allows us to queue up data and have logic run against it asynchronously.
  • #34 The interface itself allows us to introduce logic when a queue of objects is being run. POTENTIAL DEMO: CleanUpRecords
  • #35 PRO Tip: Remember when we talked about controlling context with Start and Stop test? This is also works for batch processing.
  • #36 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.
  • #38 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
  • #39 Pro Tip: In your unit test, you can fake a third party endpoint. You generate a class that will a mock a return.
  • #40 Then you sub that endpoint for what the real code will hit when it attempts to call out.
  • #41 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.
  • #42 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.
  • #43 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.
  • #44 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.
  • #45 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.
  • #46 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.
  • #47 Or we’ll see an error DEMO: JS Remoting
  • #48 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.
  • #49 So a quick overview.
  • #50 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?
  • #51 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.
  • #53 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.
  • #54 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.
  • #57 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
  • #58 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)
  • #59 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.
  • #60 Trailhead is a fast and easy way to explore the basics of building cloud apps, whether you know how to code or not. Plus, you can earn points and badges along the way! FAQ: What is Trailhead? Trailhead is an interactive learning path through the basic building blocks of the Salesforce1 Platform. Test your knowledge of the platform while earning points and badges to celebrate your achievements. What is a unit, module, or trail?
Content in Trailhead is organized into units, modules, and trails to help guide you through everything you need to know about the Salesforce1 Platform. A unit takes you through several learning objectives for a feature or tool of the Salesforce1 Platform. Most units conclude with a challenge that reinforces the learning objectives. A module is a series of units for a particular subject area. Once you’ve completed all the units in a module, you will earn a badge that will be displayed on your Salesforce Developers profile. A trail is a series of Modules, organized in a guided learning path to help you master different aspects of the Salesforce1 Platform. What is a challenge and how do they work?
A challenge is an interactive exercise that tests your knowledge of a related unit. Developers accept challenges by attempting to complete them on a Developer Edition and allowing Trailhead to assess the outcome. Developers will need to log into a Developer Edition via Trailhead to allow a challenge to be assessed. By completing a Challenge, you earn points that get added to your Salesforce Developers profile. How do I earn points and badges?
Point are earned when you complete each unit. Badges are automatically earned when you finish all the units in a module and are displayed on your Salesforce Developers profile.
  • #62 Introduce Yourselves Note: this is a slide if there is more than one presenter