Dreamforce 13 Optimizing Data Sync for Mobile Apps


Published on

Design Patterns and Techniquea to Optimize Mobile Data Synchronization.

Published in: Technology
1 Like
  • Be the first to comment

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

No notes for slide
  • Describe the architecture of a Mobile App with offline storage
  • Describe each of the fields and their purpose
  • Dreamforce 13 Optimizing Data Sync for Mobile Apps

    1. 1. Optimizing Offline Data Synchronization for Mobile Apps Teodoro Alonso (Ted), salesforce.com, Technical Solutions Architect @tgalonso
    2. 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 product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any 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 year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
    3. 3. Teodoro Alonso (Ted) Technical Solutions Architect @tgalonso
    4. 4. Introduction •By a show of hands, for those of you have implemented a mobile application that uses Salesforce data offline? •How many of you think that you accomplished your initial goals for the mobile app? •What prevented you from achieving the goals that you set for your mobile application?
    5. 5. Goal • Present a set of Good Practices and Design Patterns that help Optimize Mobile Data Synchronization. • Describe common pitfalls to avoid when dealing with sync
    6. 6. Why is Mobile Data Synchronization so difficult to implement? • Too much Data to synchronize in a reasonable amount of time. • • Users dread using the App Unreliable or slow connectivity can cause: • • • Unreliable synchronizations Synchronization that “never ends” Complex Salesforce Data Model results in: • Slow or impossible queries. • Failed queries due to governor limits
    7. 7. McGraw-Hill Education Artemis Video Artemis Movie
    8. 8. McGraw-Hill Education Artemis Application Goals • Eliminate the need to carry around a laptop on campus to access multiple apps via browser • Make the sales rep more efficient while on campus and also reduce postcampus work • Improve data quality and completeness in Salesforce, resulting in improved analytics • Implement common processes to bring new reps up to speed faster
    9. 9. McGraw-Hill Education Artemis Application • Business Use Case 1: Provide Sales Reps with a Mobile Application to help them sell products to Campus Professors by enabling them to identify the most important opportunities tied to different professors and allow them to plan these meetings using a daily plan while online or offline • Business Use Case 2: Provide Sales Reps with a way to update the opportunities, keep notes, create sample orders and update contact data online and offline. • Business Use Case 3: Provide Sales Reps with a way to update to show the targeted product based on the courses that the Professor teaches opportunities online and offline.
    10. 10. Architecture of the Artemis McGraw-Hill Education App Artemis User UIWebView MHU, Addesses Commands Frontdoor.jsp MHHE Users SFDC URL SessionID Commands SessionID VF Pages SessionID OAuth 2.0 MHHE Objects SFDC CRM Library SFDC CRM Library Accounts, Contacts, Opportunitites, Products, Addresses, Samples, etc. SFDC1 Platform Identity Connected Apps Access Token RESTframework Sync Engine Sync Access/Refresh Tokens SFDC Rest API SFDC1 Platform RestKit MHHE Objects MHHE Objects Artemis App
    11. 11. Design Pattern 1: “They don’t need all the data” The users don’t need “all the data” and you should identify the precious little data items that are truly required. Characterize the user’s need for Salesforce data • Do ride alongs to identify the data that the user’s need in a sales call • • Identify the tasks that the users do and define what tasks have the need for offline data. Talk to their managers about what are the goals of the users and what data needs to be collected offline. • Orders, Proposals, Contact, Account, Opportunities account creation/update • For the updated records, do you need more than the owned records?
    12. 12. Design Pattern 1: Persona Example
    13. 13. Design Pattern 1: “They don’t need all the data” -cont Synchronization Worksheet Object Synchronization Data Filter Account To App MHHE Mobile Sync Flag = True Fields Dependency Id Name Phone Shipping Address Address, Contact, Case Do a test “Data Pull” using the Data Loader to estimate the data payload size. .
    14. 14. Design Pattern 2: Reduce the number of objects by flattening the data model Move one or two fields from a parent to a child in a lookup relationship using formula fields to avoid having to synchronize the parent object. Reduces the number of different objects and fields to transfer. Reduces reference resolution post sync Account Id Account Owner : Lookup (User) ... AccountOwner Name: Formula (Owner.FirstName + ' ' + Owner.LastName) ... User Id ... FirstName LastName ...
    15. 15. Design Pattern 3: Let Salesforce help Sync Objects • Add the Mobile_Sync_Flag to the objects to be synchronized. Can be a Formula field or Set by batch Apex processes (Preferred). • Sync those records WHERE Mobile_Sync_Flag = true • Much more simple query • This technique can also be used to do Pseudo-OR id queries: • For example, if we can to pull all the Addresses for all the Contacts OR Accounts already downloaded to the Mobile App. We can specify the following WHERE clause: ((MHHE_Contact_Flag__c = true AND Contact__r.MHHE_Mobile_Sync_Flag__c = true) OR (MHHE_Account_Flag__c = true AND Account__r.MHHE_Mobile_Sync_Flag__c = true))
    16. 16. Design Anti-Pattern 1: The User Knows How to Resolve Conflicts • Pop a modal dialog and ask the user to resolve Synchronization Conflicts. • Stops the sync completion • Potentially error prone user interface. • Does the user have the knowledge to make the correct choices? • This Anti-Pattern results in a complex user interface with the potential for corrupt data.
    17. 17. Design Pattern 4: Take the Last Version Unless Salesforce Says Otherwise • Identify all the objects that will have bidirectional synchronization • Determines the potential conflict objects • Will a Last Modified Record Strategy work for all cases? • If so, implement this strategy. • Assumes that the field value verification can be done locally (Mobile or Salesforce) • Do you need Salesforce to verify the fields in the mobile originated record? • Implement a “Before Insert” “Before Update” trigger in Salesforce that identifies the incoming Mobile records and verifies and cleanses the fields as necessary • Have the Mobile re-Read the Upserted records to insure that it has the cleansed fields
    18. 18. Conclusion Don’t just push data to a mobile just because they might need it someday. Carefully select the objects and records that the user absolutely requires Determine the sync direction for the objects and decide on what to do for bidirectional sync conflicts. Simplify the data you send to a mobile to speed up processing post download Only pull the fields that you need from an object or their parent object Don’t allocate all the synchronization work on the client Leverage Salesforce formula fields and batch processes to preselect the data to be synchronized.
    19. 19. Ted Alonso Steve Deren Technical Solutions Architect, @tgalonso Senior Technical Consultant