Elevate workshop programmatic_2014


Published on

Published in: Technology, Business
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • The recommended agenda can be found here:
    Under the “Workshop: S1 Programmer” tab
    Errors, comments, suggestions in either the deck or the workbook can be mentioned on Josh Birk’s Chatter feed, or written up in Google Docs and shared with Josh Birk and Mario Korf.
    There is a demo org for the Warehouse ELEVATE here:
    It has:
    Enhanced Data Model
    The workflows, etc from the Basic class
    The Apex and VF from the Programmers class
    Canvas definitions from the Programmers class
    - including the Create_Delivery Invoice action
    FlickrView (also known as PuppyForce)
    Chatter Blacklist
    BEFORE YOU PRESENT – go through the slides and update:
    As these are just placeholders in the slides right now.
    THESE SPEAKER NOTES ARE NOT VERBATIM. They are there just as hints as to what to cover.
  • Introduce the day. Poll the audience for level of experience. You’ll want to know who is a Java dev and who is a new or experienced to our platform.
  • Introduce Yourselves
    Note: this is a slide if there is more than one presenter
  • Introduce Yourselves
    Note: this is a slide if there is only one presenter
  • Introduce Yourselves
    Note: this is a slide if there is more than one presenter
  • Safe Harbor
  • Change this slide to match the local internet requirements.
  • Highlight that this is not just a day of talking to them, this is a dialogue and they should ask questions as they like – even ones that don’t pertain to the current “section”. Projects they’re working on, features they have heard about, etc.
  • Since there may be experienced devs, invite the to use the IDE of their choice (Sublime, Eclipse) even if the tutorials point to Dev Console
  • They should create a brand new DE org if they have not done so recently. They should not use a Trial, Sandbox or Production org.
    Emphasize our DE orgs are free and do not expire (they are not product trials)
  • Salesforce is often thought of as a CRM company, but these stats show we have platform services in use as well
  • 1.4 million includes Force.com, Heroku and ExactTarget
  • Our platform is not merely a cloud hosting service, it is a series of tools and features that enable developers to be successful.
  • On our platform, as you building your data model – you are getting a lot more than just a relational database. You get a mobile app, right out of the gate.
  • You get our API’s, automatically extended: REST, SOAP, Bulk, Streaming
  • And our programmatic features are automatically aware of the data model as well.
  • Now some of you might have worked with out Warehouse demo application before. If you haven’t here’s a quick recap.
  • These are the core business requirements of the Warehouse application
  • Here is an overview of what our data model will look like.
    POTENTIAL DEMO: View this in Schema Builder
  • This is our first “pro tip” slide. Using these kinds of fields can increase SOQL searches.
  • Our Basics workshop covers the declarative side of our platform, but let’s do a quick review.
  • Here is an overview of what our data model will look like.
    POTENTIAL DEMO: View this in Schema Builder
  • OK, this is a quick break to make sure everyone is up and running. The workbook walks through installing the warehouse model, creating some test data and basically making sure your DE org is setup correctly. Let’s take a chance to do that.
  • For when declarative logic is not enough, we provide Apex. Apex is a cloud-based programming language, very similar to Java – except that you can code, compile and deploy all right from your Salesforce instance. You’ll see how we can create robust programmatic functions right from your browser.
  • If you are familiar with Java or C#, you are going to be familiar with Apex. It is OO and uses dot notation. However, Apex is completely cloud based – you can compile and debug right in your browser. Because it runs right in your instance it is also a “first class” citizen – meaning we can do actions right within Apex without any additional configuration or libraries.
  • Let’s take a look at an example Apex class
  • That’s what Apex is – how do we code it? It is possible to use a third party IDE like Sublime or Eclipse – but you can also code right in your browser. Our Developer Console allows you to create and edit code, debug your applications and run unit tests.
    POTENTIAL DEMO: Show Anonymous Apex in the Dev Console
  • This will be a quick review for the Force.com devs in the room.
  • That is a picture of the first ever bug. Yes, it was a real bug. To keep bugs from happening, we use unit testing.
  • Basic overview of how Unit Testing works
    POTENTIAL DEMO: Walk through TestInvoiceStatementDeletion on the demo org and run the test
  • Basic overview of how Unit Testing works
    POTENTIAL DEMO: Walk through TestInvoiceStatementDeletion on the demo org and run the test
  • Pro tip: You may want to have a unit test follow a scenario based on a specific profile. It’s pretty easy to do.
  • Pro tip: You may want to have a unit test follow a scenario based on a specific profile. It’s pretty easy to do.
  • Pro tip: You can also load your test data off a static resource, it is easier to handle large data sets and and test data can be swapped out easily.
  • Pro tip: You can also load your test data off a static resource, it is easier to handle large data sets and and test data can be swapped out easily.
  • Overview of Apex Triggers
  • Pro tip: Best to use on trigger per logic, and then you can control the flow of the logic with the system levelTrigger variable
  • Pro tip: Triggers retain scope during an execution, so if want to keep them from being hit again and again (based on other updates/workflows) you can use a static flag on the trigger to turn it “off”
  • Pro tip: We can use Triggers on Chatter. In fact:
    Potential Demo: Chatter Blacklist
  • OK, now we have two tutorials. The first is building a simple trigger on the plaform and then there is a walkthrough of a unit test.
    For the vets in the room, we’ve got a little extra credit challenge. This is in the form of a gist online, but it walks you through a more advanced version of a trigger.
  • Update this slide with specifics about lunch
  • Scheduled Apex allows us to run business logic in the background at specific intervals
  • It uses the Schedulable interface, which allows us define the execute method to control what logic will be run on the schedule
  • You can define the schedule in two ways
  • We also have Batch Apex, which is a close cousin to Scheduled Apex
  • Batch apex allows us to queue up data and have logic run against it asynchronously.
  • The interface itself allows us to introduce logic when a queue of objects is being run.
    POTENTIAL DEMO: CleanUpRecords
  • PRO Tip: Remember when we talked about controlling context with Start and Stop test? This is also works for batch processing.
  • At the beginning we talked about how your data model is automatically extended with our API’s. So out of the box, no programming, you get REST and SOAP endpoints to query and manipulate data. Basic CRUD stuff. You also get our Bulk and Streaming API for free – but we don’t have time to cover those here.
    You can also expose custom logic via endpoints using Apex.
  • We are going to focus on Apex REST today. This is how you setup an Apex REST class. The RestResource annotation defines the actual endpoint. Methods are then assigned an HTTP method. So when we hit the CaseManagement endpoint here, and we send it an HTTP Post request … it will hit the attachPic method.
    Potential DEMO: Workbench operating against MerchandiseManager class
  • Pro Tip: In your unit test, you can fake a third party endpoint. You generate a class that will a mock a return.
  • Then you sub that endpoint for what the real code will hit when it attempts to call out.
  • OK, two more tutorials – the first on Batch processing and then another on Apex REST.
  • Visualforce is the user interface sibling to Apex. It also runs in the cloud, in your instance – and it allows you to create brand new experiences for your customers and users.
  • What do we mean by components? Well you’d start with a page component, and that will define how the whole page is going to be rendered. And then you can add things like a form and fields for the form. Now everything you see here will be HTML when it gets outputted. So you’d have and HTML form, HTML input tags, etc. To the browser, it is just standard HTML.
    But how are we binding data here? We define a controller, which gets access to server-side logic. Whenever you see these brackets and that exclamation point, you’re looking at dynamically bound data which will effect how the component is rendered.
    However, the server-side logic here is a little interesting.
    POTENTIAL DEMO: Do Standard Controller demo, then go back to describe custom controllers and extensions.
  • However what we just saw there is using a viewstate. If you aren’t familiar with a viewstate, it’s a block of hashed information on the client which tracks changes – allowing us to get around the fact that HTTP is stateless.
  • We have options, though. While a lot of Visualforce relies on bound forms to transmit data (and a viewstate), we can also talk directly to Apex via JavaScript and avoid the viewstate. This is more JavaScript friendly and also has a small footprint.
  • We have options, though. While a lot of Visualforce relies on bound forms to transmit data (and a viewstate), we can also talk directly to Apex via JavaScript and avoid the viewstate. This is more JavaScript friendly and also has a small footprint.
    DEMO: JS Remoting. You could preview FindNearby, or you could do a quick example on the fly.
  • The data is going to come back to us in JSON. Note that result here might be a string, or JSON representation of an array or object.
  • Or we’ll see an error
    DEMO: JS Remoting
  • In Spring ’14 we are rolling out a preview of a new feature called Remote Objects. It lets us perform CRUD functionality without having to write an Apex class, kind of like a Standard Controller.
  • So a quick overview.
  • Now we have a tutorial on writing a Visualforce page. This page is designed to run in Salesforce1, and uses JavaScript Remoting to locate nearby warehouses.
  • Let’s talk about another kind of user interface. This is one you might already have built out, running on your own network. How can we best integrate that back into Salesforce?
  • Canvas makes that easy. With a connected app defined, Canvas handles the authentication of the current user against the third party UI. The external application can be anything the user would normally be able to see in their browser. It can then make API calls on the user’s behalf.
  • We have API’s to fit a wide range of use cases. Our REST API is very versatile, and one of the main use cases is mobile applications – and Canvas relies on the REST API to make calls back into Salesforce.
  • Before we can make a callout though, we need to authenticate right? Canvas makes this easy, and it uses two methods – but both are similar and based on the flow of OAuth. OAuth is used by Google, Facebook, Twitter, pretty much everyone on the planet to securely authenticate first party credentials with third party apps.
  • Let’s walk through the flow of OAuth.
    Demo: A great one here could be Forcecraft
  • OK, this tutorial walks us through two different applications using Canvas.
  • Update this slide with local DUG information
    For instance, we talked about how your data model automatically extends what VF and Apex can do – but what about our API’s? We have several.
    Salesforce1 Mobile is one of our offerings, but you can also create your own custom applications.
    POTENTIAL DEMO: Quick Start on forceios / forcedroid
    We also have an entire marketplace for finding, buying and selling apps.
    NOTE: Chatter Blacklist as a Labs App (Free and Unmanaged)
    Heroku provides a framework for easily deploying the applications in the language of your choice.
    POTENTIAL DEMO: Quick PHP deployment.
  • Introduce Yourselves
    Note: this is a slide if there is more than one presenter
  • Introduce Yourselves
    Note: this is a slide if there is more than one presenter
  • statue
  • Elevate workshop programmatic_2014

    1. 1. Salesforce1 Platform for Programmers
    2. 2. @forcedotcom @joshbirk @metadaddy #forcedotcom #askforce David Scruggs Principal Platform Engineer @davescruggs In/dscruggs dscruggs@salesforce.com Stewart Loewen Solution Strategist /in/stewartloewen sloewen@salesforce.com
    3. 3. Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal quarter ended July 31, 2011. This document and others are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
    4. 4. Login and get ready UofM Wireless Internet Instructions On Each Table
    5. 5. Be interactive
    6. 6. For the Eclipse fans in the room Use the Editor of Your Choice
    7. 7. http://developer.force.com/join Free Developer Environment
    8. 8. Online Workbook http://bit.ly/force_apex_book
    9. 9. Salesforce is a Platform Company. Period. -Alex Williams, TechCrunch 500M API Calls Per Day6B Lines of Apex 4M+ Apps Built on the Platform 72B Records Stored Salesforce1 Platform
    10. 10. 1.4 million…and growing
    11. 11. Core Services Chatter Multi- language Translation Workbench Email ServicesAnalytics Cloud Database Scheema 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
    12. 12. Every Object, Every Field: Salesforce1 Mobile Accessible AppExchange Apps: Dropbox Concur Evernote ServiceMax More Custom Apps and Integrations: SAP Oracle Everything Custom More Sales, Service and Marketing Accounts Cases Campaigns Dashboards More
    13. 13. Your App Every Object, Every Field: API Enabled GET POST PATCH DELETE OAuth 2.0 HTTPS
    14. 14. Every Object, Every Field: Apex and Visualforce Enabled Visualforce Pages Visualforce Components Apex Controllers Apex Triggers Custom UICustom UI Custom LogicCustom Logic
    15. 15. Warehouse Application Requirements • Track price and inventory on hand for all merchandise • Create invoices containing one or more merchandise items as a line items • Present total invoice amount and current shipping status
    16. 16. 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
    17. 17. Indexed Field • Primary Keys • Id • Name • OwnerId • Audit Dates • Created Date • Last Modified Date • Foreign Keys • Lookups • Master-Detail • CreatedBy • External ID Fields • External ID Fields • Unique Fields • Fields indexed by Salesforce Using a query with two or more indexed filters greatly increases performance
    18. 18. 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
    19. 19. 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?
    20. 20. Warehouse Data Model Merchandise Name Price Inventory Pinot $20 15 Cabernet $30 10 Malbec $20 20 Zinfandel $10 50 Invoice Number Status Count Total INV-01 Shipped 16 $370 INV-02 New 20 $200 Invoice Line Items Invoice Line Merchandise Units Sold Unit Price Value INV-01 1 Pinot 1 20 $20 INV-01 2 Cabernet 5 10 $150 INV-01 3 Malbec 10 20 $200 INV-02 1 Pinot 20 50 $200 Workflow Rule When inserted, if unit price is blank then fill it with the Merchandise price value
    21. 21. Hands On Tutorials #1: Setup your Environment
    22. 22. Apex Cloud-based programming language on Salesforce1
    23. 23. Introduction to Apex • Object-Oriented Language • Dot Notation Syntax • Cloud based compiling, debugging and unit testing • “First Class” Citizen on the Platform
    24. 24. 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
    25. 25. Developer Console • Browser Based IDE • Create and Edit Classes • Create and Edit Triggers • Run Unit Tests • Review Debug Logs
    26. 26. Hands On Tutorials #2: Using the Dev Console #3: Creating Apex Classes Extra Credit: http://bit.ly/ELEVATE-Apex-Email-EC
    27. 27. Unit Testing Code which asserts that existing logic is operating correctly
    28. 28. • Code to test code • Tests can mirror user expecations • System Asserts increase predictability • Line Coverage increase predictability Unit Testing
    29. 29. 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?
    30. 30. 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()); } }
    31. 31. 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 }
    32. 32. Static Resource Data List<Invoice__c> invoices = Test.loadData(Invoice__c.sObjectType, 'InvoiceData'); update invoices;
    33. 33. Testing Context and Asynchronous Behavior // this is where the context of your test begins Test.StartTest(); //execute future calls, batch apex, scheduled apex UtilityRESTClass.performCallout(); // this is where the context ends Text.StopTest(); System.assertEquals(a,b); //now begin assertions
    34. 34. Apex Triggers • Event Based Logic • Associated with Object Types • Before or After: • Insert • Update • Delete • Undelete
    35. 35. 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);
    36. 36. 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; }
    37. 37. 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; } } }
    38. 38. Hands On Tutorials #4: Apex Triggers #5: Apex Unit Tests Extra Credit: http://bit.ly/ELEV-triggers http://bit.ly/ELEVATE-Mock-Endpoint-EC
    39. 39. LUNCHLunch Down the hall
    40. 40. Scheduled Apex Interface for scheduling Apex jobs
    41. 41. 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(); }
    42. 42. System.schedule('testSchedule','0 0 13 * * ?', new WarehouseUtil());Via Apex Via Web UI Schedulable Interface
    43. 43. Batch Apex Apex interface for processing large datasets asynchronously
    44. 44. 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
    45. 45. 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 } }
    46. 46. 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
    47. 47. Apex Integration Using Apex with third party systems
    48. 48. 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 ); }
    49. 49. 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/
    50. 50. Unit Tests: Mock HTTP Endpoints @isTest global class MockHttp implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest req) { // Create a fake response HttpResponse res = new HttpResponse(); res.setHeader('Content-Type', 'application/json'); res.setBody('{"foo":"bar"}'); res.setStatusCode(200); return res; } }
    51. 51. Unit Tests: Mock HTTP Endpoints @isTest private class CalloutClassTest { static void testCallout() { Test.setMock(HttpCalloutMock.class, new MockHttp()); HttpResponse res = CalloutClass.getInfoFromExternalService(); // Verify response received contains fake values String actualValue = res.getBody(); String expectedValue = '{"foo":"bar"}'; System.assertEquals(actualValue, expectedValue); } }
    52. 52. Hands On Tutorials #6: Apex Batch Processing #7: Apex REST Extra Credit: http://bit.ly/ELEVATE-REST-Response-EC
    53. 53. Visualforce Component-based user interface framework on Salesforce1
    54. 54. 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
    55. 55. Hashed information block to track server side transports Viewstate
    56. 56.  Apex Forms – Visualforce component bound to an Apex Method  Javascript Remoting – Annotated Apex methods exposed to JavaScript Interacting with Apex
    57. 57. 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
    58. 58. Sample Success Message { "statusCode":200, "type":"rpc", "ref":false, "action":"IncidentReport", "method":"createIncidentReport", "result":"a072000000pt1ZLAAY", "status":true }
    59. 59. 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 }
    60. 60. Remote Objects (Preview in Spring ’14) <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
    61. 61. 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
    62. 62. Hands On Tutorials #8: Salesforce1 Visualforce Extra Credit: http://bit.ly/ELEVATE-Streaming-EC
    63. 63. Canvas Framework for embedding third party apps into Salesforce
    64. 64. 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
    65. 65. 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"} });
    66. 66. API Leveraging industry standard HTTP REST API
    67. 67. OAuth Industry standard for authenticating users for third party apps
    68. 68. Remote Application Salesforce1 Platform Sends App Credentials User logs in, Token sent to callback Confirms token Send access token Maintain session with refresh token OAuth2 Authentication Flow
    69. 69. Hands On Tutorials #9: Salesforce1 Canvas Recess: bit.ly/Forcecraft
    70. 70. Double-click to enter title Double-click to enter text The Wrap Up
    71. 71. Survey: http://bit.ly/MSP_Survey Slides: http://bit.ly/apex_workshop_slides
    72. 72. Double-click to enter title Double-click to enter text http://developer.force.com
    73. 73. Developer Groups Join a Salesforce Developer Group http://bit.ly/fdc-dugs Twin Cities Developer Group http://www.meetup.com/SFTCDUG/ Become a User Group Leader Email: April Nassi <anassi@salesforce.com>
    74. 74. LUNCHSalesforce1 APIs Family of APIs on the Salesforce1 Platform
    75. 75. LUNCHMobile SDK Development Kit for building hybrid and native iOS and Android apps
    76. 76. LUNCHAppExchange Enterprise marketplace for Salesforce1 Apps
    77. 77. LUNCHHeroku Polyglot framework for hosting applications
    78. 78. @forcedotcom @joshbirk @metadaddy #forcedotcom #askforce
    79. 79. Joshua Birk Developer Evangelist @joshbirk joshua.birk@salesforce.com Matthew Reiser Solution Architect @Matthew_Reiser mreiser@salesforce.com
    80. 80. simplicity is the ultimate form of sophistication - Da Vinci
    81. 81. Thank You