SlideShare une entreprise Scribd logo
1  sur  102
Advanced Developer Workshop
Joshua Birk
Developer Evangelist
@joshbirk
joshua.birk@salesforce.com
Gordon Jackson
Solution Architect
gjackson@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.
ETHERNET
ON
TABLE
Promo code:
salesforce13
http://bit.ly/elevate_adv
Interactive
Questions? Current projects? Feedback?
1,000,000
Salesforce Platform Developers
9 Billion
API calls last month
2.5x
Increased demand for Force.com developers
YOU
are the makers
BETA TESTING
Warning: We’re trying something new
Editor Of Choice
For the Eclipse fans in the room
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
http://developer.force.com/join
Apex Unit Testing
Platform level support for unit testing
Unit Testing
 Assert all use cases
 Maximize code coverage
 Test early, test often
o Logic without assertions
o 75% is the target
o Test right before deployment
Test Driven Development
Testing Context
// this is where the context of your test begins
Test.StartTest();
//execute future calls, batch apex, scheduled apex
// this is where the context ends
Text.StopTest();
System.assertEquals(a,b); //now begin assertions
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
}
Static Resource Data
List<Invoice__c> invoices = Test.loadData(Invoice__c.sObjectType,
'InvoiceData');
update invoices;
Mock HTTP
@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;
}
}
Mock HTTP
@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);
}
}
Unit Testing Tutorial
http://bit.ly/elevate_adv
SOQL
Salesforce Object Query Language
Indexed Fields
• Primary Keys
• Id
• Name
• OwnerId
Using a query with two or more indexed filters greatly increases performance
• Audit Dates
• Created Date
• Last Modified Date
• Foreign Keys
• Lookups
• Master-Detail
• CreatedBy
• LastModifiedBy
• External ID fields
• Unique fields
• Fields indexed by
Saleforce
SOQL + Maps
Map<Id,Id> accountFormMap = new Map<Id,Id>();
for (Client_Form__c form : [SELECT ID, Account__c FROM
Client_Form__c
WHERE Account__c
in :accountFormMap.keySet()])
{
accountFormMap.put(form.Account__c, form.Id);
}
Map<ID, Contact> m = new Map<ID, Contact>(
[SELECT Id, LastName FROM Contact]
);
Child Relationships
List<Invoice__c> invoices = [SELECT Name,
(SELECT Merchandise__r.Name
from Line_Items__r)
FROM Invoice__c];
List<Invoice__c> invoices = [SELECT Name,
(SELECT Child_Field__c
from Child_Relationship__r)
FROM Invoice__c];
SOQL Loops
public void massUpdate() {
for (List<Contact> contacts: [SELECT FirstName, LastName
FROM Contact])
{
for(Contact c : contacts) {
if (c.FirstName == 'Barbara' &&
c.LastName == 'Gordon') {
c.LastName = 'Wayne';
}
}
update contacts;
}
}
ReadOnly
<apex:page controller="SummaryStatsController" readOnly="true">
<p>Here is a statistic: {!veryLargeSummaryStat}</p>
</apex:page>
public class SummaryStatsController {
public Integer getVeryLargeSummaryStat() {
Integer closedOpportunityStats =
[SELECT COUNT() FROM Opportunity WHERE
Opportunity.IsClosed = true];
return closedOpportunityStats;
}
}
SOQL Polymorphism
List<Case> cases = [SELECT Subject,
TYPEOF What
WHEN Account THEN Phone, NumberOfEmployees
WHEN Opportunity THEN Amount, CloseDate
END
FROM Event];
Offset
SELECT Name
FROM Merchandise__c
WHERE Price__c > 5.0
ORDER BY Name
LIMIT 10
OFFSET 0
SELECT Name
FROM Merchandise__c
WHERE Price__c > 5.0
ORDER BY Name
LIMIT 10
OFFSET 10
AggregateResult
List<AggregateResult> res = [
SELECT SUM(Line_Item_Total__c) total,
Merchandise__r.Name name
from Line_Item__c
where Invoice__c = :id
Group By Merchandise__r.Name
];
List<AggregateResult> res = [
SELECT SUM(INTEGER FIELD) total,
Child_Relationship__r.Name name
from Parent__c
where Related_Field__c = :id
Group By Child_Relationship__r.Name
];
Geolocation
String q =
'SELECT ID, Name, ShippingStreet, ShippingCity from Account ';
q+= 'WHERE DISTANCE(Location__c,
GEOLOCATION('+String.valueOf(lat)';
q+= ','+String.valueOf(lng)+'), 'mi')';
q+= ' < 100';
accounts = Database.query(q);
SOSL
List<List<SObject>> allResults =
[FIND 'Tim' IN Name Fields RETURNING
lead(id, name, LastModifiedDate
WHERE LastModifiedDate > :oldestDate),
contact(id, name, LastModifiedDate
WHERE LastModifiedDate > :oldestDate),
account(id, name, LastModifiedDate
WHERE LastModifiedDate > :oldestDate),
user(id, name, LastModifiedDate
WHERE LastModifiedDate > :oldestDate)
LIMIT 5];
Visualforce Controllers
Apex for constructing dynamic pages
Viewstate
Hashed information block to track server side transports
Reducing Viewstate
//Transient data that does not get sent back,
//reduces viewstate
transient String userName {get; set;}
//Static and/or private vars
//also do not become part of the viewstate
static private integer VERSION_NUMBER = 1;
Reducing Viewstate
//Asynchronous JavaScript callback. No viewstate.
//RemoteAction is static, so has no access to Controller context
@RemoteAction
public static Account retrieveAccount(ID accountId) {
try {
Account a = [SELECT ID, Name from ACCOUNT
WHERE Id =:accountID LIMIT 1];
return a;
} catch (DMLException e) {
return null;
}
}
Handling Parameters
//check the existence of the query parameter
if(ApexPages.currentPage().getParameters().containsKey(„id‟)) {
try {
Id aid = ApexPages.currentPage().getParameters().get(„id‟);
Account a =
[SELECT Id, Name, BillingStreet FROM Account
WHERE ID =: aid];
} catch(QueryException ex) {
ApexPages.addMessage(new ApexPages.Message(
ApexPages.Severity.FATAL, ex.getMessage()));
return;
}
}
SOQL Injection
String account_name = ApexPages.currentPage().getParameters().get('name');
account_name = String.escapeSingleQuotes(account_name);
List<Account> accounts = Database.query('SELECT ID FROM
Account WHERE Name = '+account_name);
Cookies
//Cookie =
//new Cookie(String name, String value, String path,
// Integer milliseconds, Boolean isHTTPSOnly)
public PageReference setCookies() {
Cookie companyName =
new Cookie('accountName','TestCo',null,315569260,false);
ApexPages.currentPage().setCookies(new Cookie[]{companyName});
return null;
}
public String getCookieValue() {
return ApexPages.currentPage().
getCookies().get('accountName').getValue();
}
Inheritance and Construction
public with sharing class PageController
implements SiteController {
public PageController() {
}
public PageController(ApexPages.StandardController stc) {
}
Controlling Redirect
//Stay on same page
return null;
//New page, no Viewstate
PageReference newPage = new Page.NewPage();
newPage.setRedirect(true);
return newPage;
//New page, retain Viewstate
PageReference newPage = new Page.NewPage();
newPage.setRedirect(false);
return newPage;
Unit Testing Pages
//Set test page
Test.setCurrentPage(Page.VisualforcePage);
//Set test data
Account a = new Account(Name='TestCo');
insert a;
//Set test params
ApexPages.currentPage().getParameters().put('id',a.Id);
//Instatiate Controller
SomeController controller = new SomeController();
//Make assertion
System.assertEquals(controller.AccountId,a.Id)
Non-HTML Visualforce Tutorial
http://bit.ly/elevate_advhttp://bit.ly/elevate_demos_adv
Visualforce Components
Embedding content across User Interfaces
Visualforce Dashboards
<apex:page controller="retrieveCase"
tabStyle="Case">
<apex:pageBlock>
{!contactName}s Cases
<apex:pageBlockTable value="{!cases}"
var="c">
<apex:column value="{!c.status}"/>
<apex:column value="{!c.subject}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Custom Controller
Dashboard Widget
Page Overrides
Select Override
Define Override
Templates
<apex:page controller="compositionExample">
<apex:form >
<apex:insert name=”header" />
<br />
<apex:insert name=“body" />
Layout inserts
Define with
Composition
<apex:composition template="myFormComposition
<apex:define name=”header">
<apex:outputLabel value="Enter your favorite m
<apex:inputText id=”title" value="{!mealField}"
</apex:define>
<h2>Page Content</h2>
<apex:component controller="WarehouseAccounts
<apex:attribute name="lat" type="Decimal" descrip
Query" assignTo="{!lat}"/>
<apex:attribute name="long" type="Decimal" desc
Geolocation Query" assignTo="{!lng}"/>
<apex:pageBlock >
Custom Components
Define Attributes
Assign to Apex
public with sharing class WarehouseAccountsCont
public Decimal lat {get; set;}
public Decimal lng {get; set;}
private List<Account> accounts;
public WarehouseAccountsController() {}
Page Embeds
Standard Controller
Embed in Layout
<apex:page StandardController=”Account”
showHeader=“false”
<apex:canvasApp
developerName=“warehouseDev”
applicationName=“procure”
Canvas
Framework for using third party apps within Salesforce
Any Language, Any Platform
• 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
Canvas Anatomy
Geolocation Component Tutorial
http://bit.ly/elevate_adv
jQuery Integration
Visualforce with cross-browser DOM and event control
jQuery Projects
DOM Manipulation
Event Control
UI Plugins
Mobile Interfaces



noConflict() + ready
<script>
j$ = jQuery.noConflict();
j$(document).ready(function() {
//initialize our interface
});
</script>
 Keeps jQuery out of the $ function
 Resolves conflicts with existing libs
 Ready event = DOM is Ready
jQuery Functions
j$('#accountDiv').html('New HTML');
 Call Main jQuery function
 Define DOM with CSS selectors
 Perform actions via base jQuery methods or plugins
DOM Control
accountDiv = j$(id*=idname);
accountDiv.hide();
accountDiv.hide.removeClass('bDetailBlock');
accountDiv.hide.children().show();
//make this make sense
 Call common functions
 Manipulate CSS Directly
 Interact with siblings and children
 Partial CSS Selectors
Event Control
j$(".pbHeader")
.click(function() {
j$(".pbSubsection”).toggle();
});
 Add specific event handles bound to CSS selectors
 Handle specific DOM element via this
 Manipulate DOM based on current element, siblings or children
jQuery Plugins
 iCanHaz
 jqPlot
 cometD
 SlickGrid, jqGrid
Moustache compatible client side templates
Free charting library
Flexible and powerful grid widgets
Bayeux compatible Streaming API client
Streaming API Tutorial
http://bit.ly/elevate_adv
LUNCH:
Room 119
To the left, down the stairs
Apex Triggers
Event based programmatic logic
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);
//
Delegates
public class BlacklistFilterDelegate
{
public static Integer FEED_POST = 1;
public static Integer FEED_COMMENT = 2;
public static Integer USER_STATUS = 3;
List<PatternHelper> patterns {set; get;}
Map<Id, PatternHelper> matchedPosts {set; get;}
public BlacklistFilterDelegate()
{
patterns = new List<PatternHelper>();
matchedPosts = new Map<Id, PatternHelper>();
preparePatterns();
}
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;
}
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;
}
else
f.RegexValue__c = RegexHelper.toRegex(f.Word__c,
f.Match_Whole_Words_Only__c);
}
}
De-duplication Trigger Tutorial
http://bit.ly/elevate_adv
Scheduled Apex
Cron-like functionality to schedule Apex tasks
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();
}
Schedulable Interface
System.schedule('testSchedule','0 0 13 * * ?',
new WarehouseUtil());
Via Apex
Via Web UI
Batch Apex
Functionality for Apex to run continuously in the background
Batchable Interface
global with sharing class WarehouseUtil
implements Database.Batchable<sObject> {
//Batch execute interface
global Database.QueryLocator start(Database.BatchableContext BC){
//setup SOQL for scope
}
global void execute(Database.BatchableContext BC,
List<sObject> scope) {
//Execute on current scope
}
global void finish(Database.BatchableContext BC) {
//Finish and clean up context
}
Unit Testing
Test.StartTest();
ID batchprocessid = Database.executeBatch(new WarehouseUtil());
Test.StopTest();
Asynchronous Apex Tutorial
Apex Endpoints
Exposing Apex methods via SOAP and REST
OAuth
Industry standard method of user authentication
Remote
Application
Salesforce
Platform
Sends App Credentials
User logs in,
Token sent to callback
Confirms token
Send access token
Maintain session with
refresh token
OAuth2 Flow
Apex SOAP
global class MyWebService {
webService static Id makeContact(String lastName, Account a) {
Contact c = new Contact(lastName = 'Weissman',
AccountId = a.Id);
insert c;
return c.id;
}
}
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/
Apex Email
Classes to handle both incoming and outgoing email
Outgoing Email
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String body = count+' closed records older than 90 days have been deleted';
//Set addresses based on label
mail.setToAddresses(Label.emaillist.split(','));
mail.setSubject ('[Warehouse] Dated Invoices');
mail.setPlainTextBody(body);
//Send the email
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
Incoming Email
global class PageHitsController implements Messaging.InboundEmailHandler {
global Messaging.InboundEmailResult handleInboundEmail(
Messaging.inboundEmail email,
Messaging.InboundEnvelope env)
{
if(email.textAttachments.size() > 0) {
Messaging.InboundEmail.TextAttachment csvDoc =
email.textAttachments[0];
PageHitsController.uploadCSVData(csvDoc.body);
}
Messaging.InboundEmailResult result = new
Messaging.InboundEmailResult();
result.success = true;
return result;
}
Incoming Email
Define Service
Limit Accepts
Custom Endpoint Tutorial
http://bit.ly/elevate_adv
Team Development
Tools for teams and build masters
Metadata API
API to access customizations to the Force.com platform
Migration Tool
Ant based tool for deploying Force.com applications
Continuous Integration
Source
Control
Sandbox
CI Tool
DE
Fail
Notifications
Development Testing
Tooling API
Access, create and edit Force.com application code
Polyglot Framework
PaaS allowing for the deployment of multiple languages
Heroku Integration Tutorial
http://bit.ly/elevate_adv
Double-click to enter title
Double-click to enter text
The Wrap Up
check inbox ||
http://bit.ly/elevatela13
Double-click to enter title
Double-click to enter text
@forcedotcom
@joshbirk
@metadaddy
#forcedotcom
Double-click to enter title
Double-click to enter text
Join A
Developer User Group
http://bit.ly/fdc-dugs
LA DUG:
http://www.meetup.com/Los-Angeles-
Force-com-Developer-Group/
Leader: Nathan Pepper
Double-click to enter title
Double-click to enter text
Become A
Developer User Group Leader
Email:
April Nassi
<anassi@salesforce.com>
Double-click to enter title
Double-click to enter text
http://developer.force.com
http://www.slideshare.net/inkless/
elevate-advanced-workshop
simplicity
is the ultimate
form of
sophistication
Da Vinci
Thank You
Joshua Birk
Developer Evangelist
@joshbirk
joshua.birk@salesforce.com
Matthew Reiser
Solution Architect
@Matthew_Reiser
mreiser@salesforce.com

Contenu connexe

En vedette

New data centre Info Pack Version 1
New data centre Info Pack Version 1New data centre Info Pack Version 1
New data centre Info Pack Version 1Mark Underwood
 
Looking back at my preliminary task
Looking back at my preliminary taskLooking back at my preliminary task
Looking back at my preliminary taskentwistlesophie8064
 
Primero Dundee Presentation
Primero Dundee PresentationPrimero Dundee Presentation
Primero Dundee Presentationprimero_mining
 
Primero bmo conference presentation 2015 final v2
Primero bmo conference presentation 2015 final v2Primero bmo conference presentation 2015 final v2
Primero bmo conference presentation 2015 final v2primero_mining
 
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...La creazione di un Catalogo unico in linked open data delle Biblioteche delle...
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...Tiziana Possemato
 
Peran k3 dalam eksplorasi tambang bawah laut i
Peran k3 dalam eksplorasi tambang bawah laut iPeran k3 dalam eksplorasi tambang bawah laut i
Peran k3 dalam eksplorasi tambang bawah laut iSylvester Saragih
 
Primero q4 2014 presentation 2015 final
Primero q4 2014 presentation 2015 finalPrimero q4 2014 presentation 2015 final
Primero q4 2014 presentation 2015 finalprimero_mining
 
Banco de la republica
Banco de la republicaBanco de la republica
Banco de la republicacecoa
 
Ways my media product uses develop and challanges media conventions
Ways my media product uses develop and challanges media conventionsWays my media product uses develop and challanges media conventions
Ways my media product uses develop and challanges media conventionsentwistlesophie8064
 
Kuliah 10-bab-ix-kadar-batas-n-ekivalen
Kuliah 10-bab-ix-kadar-batas-n-ekivalenKuliah 10-bab-ix-kadar-batas-n-ekivalen
Kuliah 10-bab-ix-kadar-batas-n-ekivalenSylvester Saragih
 
36kr no.94
36kr no.9436kr no.94
36kr no.94Gina Gu
 
橙色精美销售模板Ppt
橙色精美销售模板Ppt橙色精美销售模板Ppt
橙色精美销售模板PptGina Gu
 
Genesa bahan galian bijih nikel laterit
Genesa bahan galian bijih nikel lateritGenesa bahan galian bijih nikel laterit
Genesa bahan galian bijih nikel lateritSylvester Saragih
 
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp0110remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp01Gina Gu
 
Q2 2013 presentation final
Q2 2013 presentation finalQ2 2013 presentation final
Q2 2013 presentation finalprimero_mining
 

En vedette (20)

New data centre Info Pack Version 1
New data centre Info Pack Version 1New data centre Info Pack Version 1
New data centre Info Pack Version 1
 
Looking back at my preliminary task
Looking back at my preliminary taskLooking back at my preliminary task
Looking back at my preliminary task
 
Primero Dundee Presentation
Primero Dundee PresentationPrimero Dundee Presentation
Primero Dundee Presentation
 
Primero bmo conference presentation 2015 final v2
Primero bmo conference presentation 2015 final v2Primero bmo conference presentation 2015 final v2
Primero bmo conference presentation 2015 final v2
 
Khasiat susu kambing
Khasiat susu kambingKhasiat susu kambing
Khasiat susu kambing
 
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...La creazione di un Catalogo unico in linked open data delle Biblioteche delle...
La creazione di un Catalogo unico in linked open data delle Biblioteche delle...
 
Primero csr 2013
Primero csr 2013Primero csr 2013
Primero csr 2013
 
Peran k3 dalam eksplorasi tambang bawah laut i
Peran k3 dalam eksplorasi tambang bawah laut iPeran k3 dalam eksplorasi tambang bawah laut i
Peran k3 dalam eksplorasi tambang bawah laut i
 
Primero q4 2014 presentation 2015 final
Primero q4 2014 presentation 2015 finalPrimero q4 2014 presentation 2015 final
Primero q4 2014 presentation 2015 final
 
General info
General infoGeneral info
General info
 
Banco de la republica
Banco de la republicaBanco de la republica
Banco de la republica
 
Bahan kuliah materi 8
Bahan kuliah materi 8Bahan kuliah materi 8
Bahan kuliah materi 8
 
Ways my media product uses develop and challanges media conventions
Ways my media product uses develop and challanges media conventionsWays my media product uses develop and challanges media conventions
Ways my media product uses develop and challanges media conventions
 
Kuliah 10-bab-ix-kadar-batas-n-ekivalen
Kuliah 10-bab-ix-kadar-batas-n-ekivalenKuliah 10-bab-ix-kadar-batas-n-ekivalen
Kuliah 10-bab-ix-kadar-batas-n-ekivalen
 
Statistika
StatistikaStatistika
Statistika
 
36kr no.94
36kr no.9436kr no.94
36kr no.94
 
橙色精美销售模板Ppt
橙色精美销售模板Ppt橙色精美销售模板Ppt
橙色精美销售模板Ppt
 
Genesa bahan galian bijih nikel laterit
Genesa bahan galian bijih nikel lateritGenesa bahan galian bijih nikel laterit
Genesa bahan galian bijih nikel laterit
 
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp0110remarkableentrepreneurshipthoughts 131008125313-phpapp01
10remarkableentrepreneurshipthoughts 131008125313-phpapp01
 
Q2 2013 presentation final
Q2 2013 presentation finalQ2 2013 presentation final
Q2 2013 presentation final
 

Similaire à Detroit ELEVATE Track 2

Seattle Dev Garage
Seattle Dev GarageSeattle Dev Garage
Seattle Dev GarageJoshua Birk
 
Building Efficient Visualforce Pages
Building Efficient Visualforce PagesBuilding Efficient Visualforce Pages
Building Efficient Visualforce PagesSalesforce Developers
 
Integrating Force.com with Heroku
Integrating Force.com with HerokuIntegrating Force.com with Heroku
Integrating Force.com with HerokuPat Patterson
 
Building Efficient Visualforce Pages
Building Efficient Visualforce PagesBuilding Efficient Visualforce Pages
Building Efficient Visualforce PagesSFDCSregan
 
Visualforce: Using ActionFunction vs. RemoteAction
Visualforce: Using ActionFunction vs. RemoteActionVisualforce: Using ActionFunction vs. RemoteAction
Visualforce: Using ActionFunction vs. RemoteActionSalesforce Developers
 
Atl elevate programmatic developer slides
Atl elevate programmatic developer slidesAtl elevate programmatic developer slides
Atl elevate programmatic developer slidesDavid Scruggs
 
Lightning Connect Custom Adapters: Connecting Anything with Salesforce
Lightning Connect Custom Adapters: Connecting Anything with SalesforceLightning Connect Custom Adapters: Connecting Anything with Salesforce
Lightning Connect Custom Adapters: Connecting Anything with SalesforceSalesforce Developers
 
Javascript and Remote Objects on Force.com Winter 15
Javascript and Remote Objects on Force.com Winter 15Javascript and Remote Objects on Force.com Winter 15
Javascript and Remote Objects on Force.com Winter 15Peter Chittum
 
Developing Offline Mobile Apps with the Salesforce.com Mobile SDK SmartStore,...
Developing Offline Mobile Apps with the Salesforce.com Mobile SDK SmartStore,...Developing Offline Mobile Apps with the Salesforce.com Mobile SDK SmartStore,...
Developing Offline Mobile Apps with the Salesforce.com Mobile SDK SmartStore,...Tom Gersic
 
Salesforce1 Platform ELEVATE LA workshop Dec 18, 2013
Salesforce1 Platform ELEVATE LA workshop Dec 18, 2013Salesforce1 Platform ELEVATE LA workshop Dec 18, 2013
Salesforce1 Platform ELEVATE LA workshop Dec 18, 2013Salesforce Developers
 
Elevate workshop programmatic_2014
Elevate workshop programmatic_2014Elevate workshop programmatic_2014
Elevate workshop programmatic_2014David Scruggs
 
Introduction to Visualforce for Mobile Devices
Introduction to Visualforce for Mobile DevicesIntroduction to Visualforce for Mobile Devices
Introduction to Visualforce for Mobile DevicesSalesforce Developers
 
S1 and Visualforce Publisher Actions
S1 and Visualforce Publisher ActionsS1 and Visualforce Publisher Actions
S1 and Visualforce Publisher ActionsPeter Chittum
 
Advanced Apex Webinar
Advanced Apex WebinarAdvanced Apex Webinar
Advanced Apex Webinarpbattisson
 
Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex! Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex! Salesforce Developers
 

Similaire à Detroit ELEVATE Track 2 (20)

ELEVATE Paris
ELEVATE ParisELEVATE Paris
ELEVATE Paris
 
Seattle Dev Garage
Seattle Dev GarageSeattle Dev Garage
Seattle Dev Garage
 
Introduction to Apex for Developers
Introduction to Apex for DevelopersIntroduction to Apex for Developers
Introduction to Apex for Developers
 
Building Efficient Visualforce Pages
Building Efficient Visualforce PagesBuilding Efficient Visualforce Pages
Building Efficient Visualforce Pages
 
Integrating Force.com with Heroku
Integrating Force.com with HerokuIntegrating Force.com with Heroku
Integrating Force.com with Heroku
 
Building Efficient Visualforce Pages
Building Efficient Visualforce PagesBuilding Efficient Visualforce Pages
Building Efficient Visualforce Pages
 
Speed of Lightning
Speed of LightningSpeed of Lightning
Speed of Lightning
 
Visualforce: Using ActionFunction vs. RemoteAction
Visualforce: Using ActionFunction vs. RemoteActionVisualforce: Using ActionFunction vs. RemoteAction
Visualforce: Using ActionFunction vs. RemoteAction
 
Atl elevate programmatic developer slides
Atl elevate programmatic developer slidesAtl elevate programmatic developer slides
Atl elevate programmatic developer slides
 
Lightning Connect Custom Adapters: Connecting Anything with Salesforce
Lightning Connect Custom Adapters: Connecting Anything with SalesforceLightning Connect Custom Adapters: Connecting Anything with Salesforce
Lightning Connect Custom Adapters: Connecting Anything with Salesforce
 
Javascript and Remote Objects on Force.com Winter 15
Javascript and Remote Objects on Force.com Winter 15Javascript and Remote Objects on Force.com Winter 15
Javascript and Remote Objects on Force.com Winter 15
 
Apex Design Patterns
Apex Design PatternsApex Design Patterns
Apex Design Patterns
 
Developing Offline Mobile Apps with the Salesforce.com Mobile SDK SmartStore,...
Developing Offline Mobile Apps with the Salesforce.com Mobile SDK SmartStore,...Developing Offline Mobile Apps with the Salesforce.com Mobile SDK SmartStore,...
Developing Offline Mobile Apps with the Salesforce.com Mobile SDK SmartStore,...
 
Salesforce1 Platform ELEVATE LA workshop Dec 18, 2013
Salesforce1 Platform ELEVATE LA workshop Dec 18, 2013Salesforce1 Platform ELEVATE LA workshop Dec 18, 2013
Salesforce1 Platform ELEVATE LA workshop Dec 18, 2013
 
Elevate workshop programmatic_2014
Elevate workshop programmatic_2014Elevate workshop programmatic_2014
Elevate workshop programmatic_2014
 
Introduction to Visualforce for Mobile Devices
Introduction to Visualforce for Mobile DevicesIntroduction to Visualforce for Mobile Devices
Introduction to Visualforce for Mobile Devices
 
Intro to Apex Programmers
Intro to Apex ProgrammersIntro to Apex Programmers
Intro to Apex Programmers
 
S1 and Visualforce Publisher Actions
S1 and Visualforce Publisher ActionsS1 and Visualforce Publisher Actions
S1 and Visualforce Publisher Actions
 
Advanced Apex Webinar
Advanced Apex WebinarAdvanced Apex Webinar
Advanced Apex Webinar
 
Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex! Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex!
 

Plus de Joshua Birk

Detroit ELEVATE Track 1
Detroit ELEVATE Track 1Detroit ELEVATE Track 1
Detroit ELEVATE Track 1Joshua Birk
 
Platform integration
Platform integrationPlatform integration
Platform integrationJoshua Birk
 
Sao Paolo Workshop
Sao Paolo WorkshopSao Paolo Workshop
Sao Paolo WorkshopJoshua Birk
 
Mobile SDK + Cordova
Mobile SDK + CordovaMobile SDK + Cordova
Mobile SDK + CordovaJoshua Birk
 

Plus de Joshua Birk (7)

Detroit ELEVATE Track 1
Detroit ELEVATE Track 1Detroit ELEVATE Track 1
Detroit ELEVATE Track 1
 
Workshop slides
Workshop slidesWorkshop slides
Workshop slides
 
Platform integration
Platform integrationPlatform integration
Platform integration
 
Brasil Roadshow
Brasil RoadshowBrasil Roadshow
Brasil Roadshow
 
Sao Paolo Workshop
Sao Paolo WorkshopSao Paolo Workshop
Sao Paolo Workshop
 
Mobile SDK + Cordova
Mobile SDK + CordovaMobile SDK + Cordova
Mobile SDK + Cordova
 
Blue converter
Blue converterBlue converter
Blue converter
 

Dernier

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Dernier (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

Detroit ELEVATE Track 2

  • 1. Advanced Developer Workshop Joshua Birk Developer Evangelist @joshbirk joshua.birk@salesforce.com Gordon Jackson Solution Architect gjackson@salesforce.com
  • 2. 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.
  • 6. 9 Billion API calls last month
  • 7. 2.5x Increased demand for Force.com developers
  • 9. BETA TESTING Warning: We’re trying something new
  • 10. Editor Of Choice For the Eclipse fans in the room
  • 11. 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
  • 13. Apex Unit Testing Platform level support for unit testing
  • 14. Unit Testing  Assert all use cases  Maximize code coverage  Test early, test often o Logic without assertions o 75% is the target o Test right before deployment
  • 16. Testing Context // this is where the context of your test begins Test.StartTest(); //execute future calls, batch apex, scheduled apex // this is where the context ends Text.StopTest(); System.assertEquals(a,b); //now begin assertions
  • 17. 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 }
  • 18. Static Resource Data List<Invoice__c> invoices = Test.loadData(Invoice__c.sObjectType, 'InvoiceData'); update invoices;
  • 19. Mock HTTP @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; } }
  • 20. Mock HTTP @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); } }
  • 23. Indexed Fields • Primary Keys • Id • Name • OwnerId Using a query with two or more indexed filters greatly increases performance • Audit Dates • Created Date • Last Modified Date • Foreign Keys • Lookups • Master-Detail • CreatedBy • LastModifiedBy • External ID fields • Unique fields • Fields indexed by Saleforce
  • 24. SOQL + Maps Map<Id,Id> accountFormMap = new Map<Id,Id>(); for (Client_Form__c form : [SELECT ID, Account__c FROM Client_Form__c WHERE Account__c in :accountFormMap.keySet()]) { accountFormMap.put(form.Account__c, form.Id); } Map<ID, Contact> m = new Map<ID, Contact>( [SELECT Id, LastName FROM Contact] );
  • 25. Child Relationships List<Invoice__c> invoices = [SELECT Name, (SELECT Merchandise__r.Name from Line_Items__r) FROM Invoice__c]; List<Invoice__c> invoices = [SELECT Name, (SELECT Child_Field__c from Child_Relationship__r) FROM Invoice__c];
  • 26. SOQL Loops public void massUpdate() { for (List<Contact> contacts: [SELECT FirstName, LastName FROM Contact]) { for(Contact c : contacts) { if (c.FirstName == 'Barbara' && c.LastName == 'Gordon') { c.LastName = 'Wayne'; } } update contacts; } }
  • 27. ReadOnly <apex:page controller="SummaryStatsController" readOnly="true"> <p>Here is a statistic: {!veryLargeSummaryStat}</p> </apex:page> public class SummaryStatsController { public Integer getVeryLargeSummaryStat() { Integer closedOpportunityStats = [SELECT COUNT() FROM Opportunity WHERE Opportunity.IsClosed = true]; return closedOpportunityStats; } }
  • 28. SOQL Polymorphism List<Case> cases = [SELECT Subject, TYPEOF What WHEN Account THEN Phone, NumberOfEmployees WHEN Opportunity THEN Amount, CloseDate END FROM Event];
  • 29. Offset SELECT Name FROM Merchandise__c WHERE Price__c > 5.0 ORDER BY Name LIMIT 10 OFFSET 0 SELECT Name FROM Merchandise__c WHERE Price__c > 5.0 ORDER BY Name LIMIT 10 OFFSET 10
  • 30. AggregateResult List<AggregateResult> res = [ SELECT SUM(Line_Item_Total__c) total, Merchandise__r.Name name from Line_Item__c where Invoice__c = :id Group By Merchandise__r.Name ]; List<AggregateResult> res = [ SELECT SUM(INTEGER FIELD) total, Child_Relationship__r.Name name from Parent__c where Related_Field__c = :id Group By Child_Relationship__r.Name ];
  • 31. Geolocation String q = 'SELECT ID, Name, ShippingStreet, ShippingCity from Account '; q+= 'WHERE DISTANCE(Location__c, GEOLOCATION('+String.valueOf(lat)'; q+= ','+String.valueOf(lng)+'), 'mi')'; q+= ' < 100'; accounts = Database.query(q);
  • 32. SOSL List<List<SObject>> allResults = [FIND 'Tim' IN Name Fields RETURNING lead(id, name, LastModifiedDate WHERE LastModifiedDate > :oldestDate), contact(id, name, LastModifiedDate WHERE LastModifiedDate > :oldestDate), account(id, name, LastModifiedDate WHERE LastModifiedDate > :oldestDate), user(id, name, LastModifiedDate WHERE LastModifiedDate > :oldestDate) LIMIT 5];
  • 33. Visualforce Controllers Apex for constructing dynamic pages
  • 34. Viewstate Hashed information block to track server side transports
  • 35. Reducing Viewstate //Transient data that does not get sent back, //reduces viewstate transient String userName {get; set;} //Static and/or private vars //also do not become part of the viewstate static private integer VERSION_NUMBER = 1;
  • 36. Reducing Viewstate //Asynchronous JavaScript callback. No viewstate. //RemoteAction is static, so has no access to Controller context @RemoteAction public static Account retrieveAccount(ID accountId) { try { Account a = [SELECT ID, Name from ACCOUNT WHERE Id =:accountID LIMIT 1]; return a; } catch (DMLException e) { return null; } }
  • 37. Handling Parameters //check the existence of the query parameter if(ApexPages.currentPage().getParameters().containsKey(„id‟)) { try { Id aid = ApexPages.currentPage().getParameters().get(„id‟); Account a = [SELECT Id, Name, BillingStreet FROM Account WHERE ID =: aid]; } catch(QueryException ex) { ApexPages.addMessage(new ApexPages.Message( ApexPages.Severity.FATAL, ex.getMessage())); return; } }
  • 38. SOQL Injection String account_name = ApexPages.currentPage().getParameters().get('name'); account_name = String.escapeSingleQuotes(account_name); List<Account> accounts = Database.query('SELECT ID FROM Account WHERE Name = '+account_name);
  • 39. Cookies //Cookie = //new Cookie(String name, String value, String path, // Integer milliseconds, Boolean isHTTPSOnly) public PageReference setCookies() { Cookie companyName = new Cookie('accountName','TestCo',null,315569260,false); ApexPages.currentPage().setCookies(new Cookie[]{companyName}); return null; } public String getCookieValue() { return ApexPages.currentPage(). getCookies().get('accountName').getValue(); }
  • 40. Inheritance and Construction public with sharing class PageController implements SiteController { public PageController() { } public PageController(ApexPages.StandardController stc) { }
  • 41. Controlling Redirect //Stay on same page return null; //New page, no Viewstate PageReference newPage = new Page.NewPage(); newPage.setRedirect(true); return newPage; //New page, retain Viewstate PageReference newPage = new Page.NewPage(); newPage.setRedirect(false); return newPage;
  • 42. Unit Testing Pages //Set test page Test.setCurrentPage(Page.VisualforcePage); //Set test data Account a = new Account(Name='TestCo'); insert a; //Set test params ApexPages.currentPage().getParameters().put('id',a.Id); //Instatiate Controller SomeController controller = new SomeController(); //Make assertion System.assertEquals(controller.AccountId,a.Id)
  • 45. Visualforce Dashboards <apex:page controller="retrieveCase" tabStyle="Case"> <apex:pageBlock> {!contactName}s Cases <apex:pageBlockTable value="{!cases}" var="c"> <apex:column value="{!c.status}"/> <apex:column value="{!c.subject}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page> Custom Controller Dashboard Widget
  • 47. Templates <apex:page controller="compositionExample"> <apex:form > <apex:insert name=”header" /> <br /> <apex:insert name=“body" /> Layout inserts Define with Composition <apex:composition template="myFormComposition <apex:define name=”header"> <apex:outputLabel value="Enter your favorite m <apex:inputText id=”title" value="{!mealField}" </apex:define> <h2>Page Content</h2>
  • 48. <apex:component controller="WarehouseAccounts <apex:attribute name="lat" type="Decimal" descrip Query" assignTo="{!lat}"/> <apex:attribute name="long" type="Decimal" desc Geolocation Query" assignTo="{!lng}"/> <apex:pageBlock > Custom Components Define Attributes Assign to Apex public with sharing class WarehouseAccountsCont public Decimal lat {get; set;} public Decimal lng {get; set;} private List<Account> accounts; public WarehouseAccountsController() {}
  • 49. Page Embeds Standard Controller Embed in Layout <apex:page StandardController=”Account” showHeader=“false” <apex:canvasApp developerName=“warehouseDev” applicationName=“procure”
  • 50. Canvas Framework for using third party apps within Salesforce
  • 51.
  • 52. Any Language, Any Platform • 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 Canvas Anatomy
  • 54. jQuery Integration Visualforce with cross-browser DOM and event control
  • 55. jQuery Projects DOM Manipulation Event Control UI Plugins Mobile Interfaces   
  • 56. noConflict() + ready <script> j$ = jQuery.noConflict(); j$(document).ready(function() { //initialize our interface }); </script>  Keeps jQuery out of the $ function  Resolves conflicts with existing libs  Ready event = DOM is Ready
  • 57. jQuery Functions j$('#accountDiv').html('New HTML');  Call Main jQuery function  Define DOM with CSS selectors  Perform actions via base jQuery methods or plugins
  • 58. DOM Control accountDiv = j$(id*=idname); accountDiv.hide(); accountDiv.hide.removeClass('bDetailBlock'); accountDiv.hide.children().show(); //make this make sense  Call common functions  Manipulate CSS Directly  Interact with siblings and children  Partial CSS Selectors
  • 59. Event Control j$(".pbHeader") .click(function() { j$(".pbSubsection”).toggle(); });  Add specific event handles bound to CSS selectors  Handle specific DOM element via this  Manipulate DOM based on current element, siblings or children
  • 60. jQuery Plugins  iCanHaz  jqPlot  cometD  SlickGrid, jqGrid Moustache compatible client side templates Free charting library Flexible and powerful grid widgets Bayeux compatible Streaming API client
  • 62. LUNCH: Room 119 To the left, down the stairs
  • 63. Apex Triggers Event based programmatic logic
  • 64. 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); //
  • 65. Delegates public class BlacklistFilterDelegate { public static Integer FEED_POST = 1; public static Integer FEED_COMMENT = 2; public static Integer USER_STATUS = 3; List<PatternHelper> patterns {set; get;} Map<Id, PatternHelper> matchedPosts {set; get;} public BlacklistFilterDelegate() { patterns = new List<PatternHelper>(); matchedPosts = new Map<Id, PatternHelper>(); preparePatterns(); }
  • 66. 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; }
  • 67. 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; } else f.RegexValue__c = RegexHelper.toRegex(f.Word__c, f.Match_Whole_Words_Only__c); } }
  • 69. Scheduled Apex Cron-like functionality to schedule Apex tasks
  • 70. 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(); }
  • 71. Schedulable Interface System.schedule('testSchedule','0 0 13 * * ?', new WarehouseUtil()); Via Apex Via Web UI
  • 72. Batch Apex Functionality for Apex to run continuously in the background
  • 73. Batchable Interface global with sharing class WarehouseUtil implements Database.Batchable<sObject> { //Batch execute interface global Database.QueryLocator start(Database.BatchableContext BC){ //setup SOQL for scope } global void execute(Database.BatchableContext BC, List<sObject> scope) { //Execute on current scope } global void finish(Database.BatchableContext BC) { //Finish and clean up context }
  • 74. Unit Testing Test.StartTest(); ID batchprocessid = Database.executeBatch(new WarehouseUtil()); Test.StopTest();
  • 76. Apex Endpoints Exposing Apex methods via SOAP and REST
  • 77. OAuth Industry standard method of user authentication
  • 78. Remote Application Salesforce Platform Sends App Credentials User logs in, Token sent to callback Confirms token Send access token Maintain session with refresh token OAuth2 Flow
  • 79. Apex SOAP global class MyWebService { webService static Id makeContact(String lastName, Account a) { Contact c = new Contact(lastName = 'Weissman', AccountId = a.Id); insert c; return c.id; } }
  • 80. 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/
  • 81. Apex Email Classes to handle both incoming and outgoing email
  • 82. Outgoing Email Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String body = count+' closed records older than 90 days have been deleted'; //Set addresses based on label mail.setToAddresses(Label.emaillist.split(',')); mail.setSubject ('[Warehouse] Dated Invoices'); mail.setPlainTextBody(body); //Send the email Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
  • 83. Incoming Email global class PageHitsController implements Messaging.InboundEmailHandler { global Messaging.InboundEmailResult handleInboundEmail( Messaging.inboundEmail email, Messaging.InboundEnvelope env) { if(email.textAttachments.size() > 0) { Messaging.InboundEmail.TextAttachment csvDoc = email.textAttachments[0]; PageHitsController.uploadCSVData(csvDoc.body); } Messaging.InboundEmailResult result = new Messaging.InboundEmailResult(); result.success = true; return result; }
  • 86. Team Development Tools for teams and build masters
  • 87. Metadata API API to access customizations to the Force.com platform
  • 88. Migration Tool Ant based tool for deploying Force.com applications
  • 90. Tooling API Access, create and edit Force.com application code
  • 91.
  • 92. Polyglot Framework PaaS allowing for the deployment of multiple languages
  • 93.
  • 95. Double-click to enter title Double-click to enter text The Wrap Up
  • 97. Double-click to enter title Double-click to enter text @forcedotcom @joshbirk @metadaddy #forcedotcom
  • 98. Double-click to enter title Double-click to enter text Join A Developer User Group http://bit.ly/fdc-dugs LA DUG: http://www.meetup.com/Los-Angeles- Force-com-Developer-Group/ Leader: Nathan Pepper
  • 99. Double-click to enter title Double-click to enter text Become A Developer User Group Leader Email: April Nassi <anassi@salesforce.com>
  • 100. Double-click to enter title Double-click to enter text http://developer.force.com http://www.slideshare.net/inkless/ elevate-advanced-workshop
  • 101. simplicity is the ultimate form of sophistication Da Vinci
  • 102. Thank You Joshua Birk Developer Evangelist @joshbirk joshua.birk@salesforce.com Matthew Reiser Solution Architect @Matthew_Reiser mreiser@salesforce.com

Notes de l'éditeur

  1. Check this again – find that transaction / average time stat
  2. Here is an overview of what our data model will look like. Recommended: Break into a demo of building data in the browser, either custom object wizard or schema builder depending on audience/workbooks
  3. We are going to start the day by talking about unit testing, and then in a bit SOQL. Because these are aspects of the platform which are really a dialtone, something we should be constantly evolving with.And yes, that’s a real bug. The first real bug.So if our new fictional job is to enhance this existing Warehouse application, how we write our unit tests are going to be very important.
  4. So let’s talk about what some of your best practices are? Or if you’re brave, some of your worst?OK, let’s actually look at some really bad examples.
  5. So to recap – Unit Tests should prove out not just code, but use cases. You should try to cover as much of your code as possible. And when should you test?
  6. One theor
  7. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  8. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  9. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  10. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  11. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  12. Indexed fields are fields tracked specifically by the database, and hence can lend to greater performance when your queries use them.
  13. Apex can automatically create Maps from any SOQL result, and you can use that feature to either easily loop through the results or even to easily track the result in the map. For instance, the example here on the bottom would make it possible to find a specific contact in the result with one call from the map.
  14. It’s also good to remember that you can pull children from the parent in one SOQL call. Let’s take a look at that in the Dev Console.SELECT Name, (SELECT Merchandise__r.Name from Line_Items__r) from Invoice__c LIMIT 5
  15. You can also assign the SOQL result directly to a list, and then loop through that array. This allows you to quickly bulkify your code by generating loops and then performing any necessary DML when those loops are done.
  16. One feature added recently to SOQL was the ability to use a readOnly annotation or flag to declare the results unusable in DML, but greatly expanding the number of results that can be handles. For instance, this visualforce page would normally only be able to handle an array of 1,000, but with readOnly that limit is relaxed to 10,000.
  17. Some of the fields in the database are polymorphic, but until a few releases ago – SOQL didn’t really recognize that fact. Now that it does, you can cue specific results from those fields based on their Sobject type. Here’s an example in the Dev Console.SELECT Subject, TYPEOF What WHEN Account THEN Phone, NumberOfEmployees WHEN Opportunity THEN Amount, CloseDate ENDFROM Event
  18. OFFSET allows you to create paginated results easily. The query on the left would give us the first 10 results, and the query on the right would give us the next 10. To see that in the Dev Console:SELECT NAME from Merchandise__c LIMIT 5 OFFSET 0SELECT NAME from Merchandise__c LIMIT 5 OFFSET 10(Or use Contact depending on the org)Now one key limit on OFFSET is that the maximum offset is 2000, so you’ll need to be paginating through a recordset smaller than that.
  19. Aggregate searches allow a developer to do powerful mathematical searches against the database. In the example on the top here, you’ll get a count of merchandise by name for a specific invoice. Think of it like a highly customizable rollup field.The example on the bottom takes that same search, but shows you how it is split up. We’re summarizing an integer field, getting a child name field and then grouping it by that field. Here’s another example, where we can see how much a line item is worth by merchandise:SELECT SUM(Quantity__c) quantity, Merchandise__r.Name name from Line_Item__c Group By Merchandise__r.Name
  20. The platform now supports geolocation. In order to do a dynamic search, like above, you’ll need to construct the string and then use a dynamic query. Using these queries, you could easily gather data based on physical location, for instance if you wanted to find the contact closest to where you parked.Here’s an example in the dev console:SELECT Name FROM Account WHERE DISTANCE(Location__c, GEOLOCATION(37.7945391,-122.3947166), &apos;mi&apos;) &lt; 1
  21. So SOSL isn’t exactly new – we’ve had in the system for some time. But if you are trying to search across different Sobject types, nothing beats it. Here we can find Tim even if he is a contact or account. Let’s look at an example in the Dev Console:FIND {Tim} IN Name Fields RETURNING lead(id, name), contact(id, name, LastModifiedDate), account(id, name, LastModifiedDate), user(id, name, LastModifiedDate) LIMIT 5
  22. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  23. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  24. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  25. Explain the ID trick, - for SOQL injection protection
  26. Explain the ID trick, - for SOQL injection protection
  27. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  28. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  29. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  30. Controller testing should also include page reference asserts if you are moving from page to page
  31. We’re used to thinking about Visualforce as a component based library, and that let’s us create HTML based interfaces very quickly and easily by binding those components to data. But what about using those components to mix and match Visualforce across your instance?
  32. For instance, you can use Visualforce to create very custom dashboards, and then put those on your homepage. Here’s an example I’ve got with the Warehouse app, which is showing recently created Invoices:( /home/home.jsp )Now if I click into one of those Invoices, we’re also seeing visualforce.
  33. Because, and this is probably one of the more common use cases for Visualforce, anything with a Standard Controller can be used in place of the standard list, view, edit style pages. On this page, I’m still displaying the page layout via the detail component, but we wanted to be able to leverage a new footer across different detail pages(show WarehouseDetail
  34. And we’re keeping that new detail consistent by using a template. We can define our inserts, and then define our content. This allows us to maintain a lot of different look and feels across different object types, but controlling the parts that will the same in one place.
  35. And of course, as we customize that layout, we can create custom components which can take incoming attributes and then render what we need. For instance, in my footer I am using a visualization jQuery plugin called isotope, which allows us to view the line items in a very different way than the related list. You’ll see more about jQuery later.
  36. And of course, if I want that Visualforce in the middle of my layout, I can use a StandardController to embed that right into it. In fact, in this layout – this section is not being generated here on Salesforce.
  37. It’s actually using Canvas, which allows me to easily put third part applications into Salesforce in a secure manner.
  38. For instance, maybe I have a large internal intranet applications. I don’t want to port all that functionality into Salesforce, but I do want to be able to integrate this one interface.
  39. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  40. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  41. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  42. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  43. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  44. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  45. Apex controllers are probably the most common use case for the language, but triggers merit a second place.
  46. And with all of those potentials triggers in your system, they can easily get out of hand. There are a few best practices people have found to make them more maintainable.First, consider having only one trigger per object. Within the trigger class itself, break out every possible event, before and after, and start putting system.debugs around them. At the very least, this will make it very easy to track down in debug logs where the logic is getting fired.Second, consider handing off the actual logic to delegate classes. Send them the current scope of the trigger and let them sort it out. This will neatly divide the functionality that your trigger is trying to accomplish.
  47. A delegate also gives you more breathing room. Look at all the variables we are using to properly track what this delegate wants to do – if you started stacking all the logic into the trigger itself, this will start to get unruly really fast. Don’t let your triggers become a battleground, they should be more like highways.
  48. Another trick is using static variables in another class to track progress in your trigger. Changes to these flags will be visible for the span of the trigger context. So if, for instance, another process kicks off your trigger logic a second time, and you don’t want it to – you could swap the first flag here to true, and then not execute any logic if that flag is true.
  49. And remember one of the more powerful uses of triggers is in association with Chatter. Let’s take a look at a Force.com labs app, Chatter Blacklist, which illustrates this very well.
  50. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  51. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  52. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  53. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  54. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  55. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  56. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  57. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  58. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  59. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  60. Self Service case structure by Email
  61. Update this subtitle
  62. How does privacy work with Chatter? Can you accidentally share a record I’m not supposed to see?
  63. statue