Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using the Database.com Ruby Gem to integrate with Force.com

Brian Garside
September 20, 2012

Using the Database.com Ruby Gem to integrate with Force.com

A presentation given at DreamForce 2012 about Info-Tech's open sourced gem "salesforce ar sync" (clever name to be determined later). - I didn't give this presentation, but I helped build the deck for Mike and Liam.

If you have a better name, tweet it under the hash tag #sfarsync

Brian Garside

September 20, 2012
Tweet

More Decks by Brian Garside

Other Decks in Technology

Transcript

  1. Using the Database.com Ruby Gem to integrate with Force.com Active

    Syncing between Salesforce and Rails Liam Nediger - Salesforce Architect - @lnediger Michael Halliday – Rails Architect - @mphalliday Info-Tech Research Group
  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 intellectual property and other litigation, 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-Q for the most recent fiscal quarter ended July 31, 2012. This 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. All about Info-Tech Info-Tech is a Research and Advisory Firm

    We use Salesforce as our CRM We have a Ruby on Rails app as our Website §  We sell memberships to a website which gives our clients access to: §  Best practice research §  Access to our analysts §  Tools and Templates §  Benchmarking tools §  Workshops to improve IT operations §  www.infotech.com
  4. Session Overview: •  Case Study: The Info-Tech Messaging System • 

    First Solution •  Second Solution •  Gemification •  Where We Go From Here
  5. Record Changes •  Salesforce revision logs (custom objects), updated on

    change •  Black Box ran SOQL query every 5-30 seconds •  If Salesforce and Web revision numbers different, then: •  Black Box took changes from Salesforce (via SOAP). •  Converted the SOAP to XML •  Sent the XML to the website •  REST service would CRUD users with XML data
  6. How did we get here? •  In 2009, primarily a

    .NET shop •  October 2009 – Launched RoR Website •  August 2010 – Upgraded to Salesforce •  August 2010 – Simplified content access on RoR Website •  August 2010 – Changed entire membership structure
  7. A solution Got smart people together. • Why are we going

    through a black box? • What do we actually need to accomplish? • Why can't we just go direct to Salesforce and back again?
  8. The Solution •  Outbound messaging which will package up little

    SOAP messages, and sends them out •  Outbound messaging is redundant, if it doesn't get a SOAP confirmation back, then it continues to try to deliver it until it gets that confirmation. •  Built a simple SOAP decoder on the website
  9. A Rethink •  Smart people in a room •  +

    Whiteboard •  - Distractions •  Ask: “How would this work in an ideal world?”
  10. Our ideal solution using our most complex object: •  Asynchronous

    attributes •  Optionally sync on a per record basis •  (logic to determine what should be synced) •  One way syncing •  Be able to handle associated records •  If you're on the website and doing a real time save, your save should win (no locking or weird logic), if a user is saving data on the website it will overwrite Salesforce data •  Only send the data that has changed at a field level
  11. Start with an Active Record Class ! class User <

    ActiveRecord::Base salesforce_syncable :sync_attributes => { :FirstName => :first_name, :LastName=> :last_name, :AccountId => :salesforce_account_id } end
  12. All about Salesforce AR Sync It’s a GEM! It’s a

    repository on GitHub It’s a Rails engine Has a full test suite §  http://github.com/infotech/salesforce_ar_sync §  Has controllers and routes for handling outbound messages §  Easy syntax for making models sync to Salesforce
  13. Outbound Message: Contact (Salesforce) Id: 00384859d8kdk3999290dk AccountId: 001939490dkeidek FirstName: Liam

    LastName: Nediger Contact Record (Rails) id: 1 account_id: 2 first_name: Liam last_name: Nediger
  14. Mapping class Contact < ActiveRecord::Base salesforce_syncable :sync_attributes => { :FirstName

    => :first_name, :LastName=> :last_name, :AccountId => :salesforce_account_id } end
  15. Association class Contact < ActiveRecord::Base ... def salesforce_account_id=(account_id) self.account =

    nil and return if account_id.nil? self.account = Account.find_or_create_by_salesforce_id(account_id) end def salesforce_account_id account.try(:salesforce_id) end end
  16. Constraints •  Rails 3.1+ •  Built in dependency on delayed

    jobs. •  Deletes from Salesforce •  Contact & Lead merges •  Async attribute syncing
  17. Sample App •  Sample rails app with gem •  Deployable

    to Heroku http://github.com/infotech/sf_sync_demo
  18. Future Improvements •  Eliminate delayed job dependency •  Better support

    for Asynchronous Attributes •  Better name! #sfarsync •  FORK IT ON GITHUB! http://github.com/infotech/salesforce_ar_sync
  19. Liam Nediger @lnediger [email protected] Michael Halliday @mphalliday [email protected] Read This

    Talk Get the Gem itblog.infotech.com/talks github.com/infotech/ sf_ar_sync