Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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.

Slide 3

Slide 3 text

Liam Nediger Salesforce architect – Info-Tech @lnediger Michael Halliday Rails architect – Info-Tech @mhalliday

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

Session Overview: •  Case Study: The Info-Tech Messaging System •  First Solution •  Second Solution •  Gemification •  Where We Go From Here

Slide 6

Slide 6 text

Our System Salesforce CRM: • Contacts • Accounts • Memberships • Subscriptions RoR Website: • Users • Account • Memberships • Subscriptions

Slide 7

Slide 7 text

In the beginning…

Slide 8

Slide 8 text

First Solution

Slide 9

Slide 9 text

Black Box and XML

Slide 10

Slide 10 text

Black Box and SOAP

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

How that looked

Slide 13

Slide 13 text

Add membership tiers

Slide 14

Slide 14 text

WAIT A MINUTE! How did we get here?

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Created a Bandage

Slide 17

Slide 17 text

Black Box Pain Points

Slide 18

Slide 18 text

Like an old and rickety bridge

Slide 19

Slide 19 text

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?

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

Rails Black Box

Slide 22

Slide 22 text

Rails Black Box

Slide 23

Slide 23 text

A Rethink •  Smart people in a room •  + Whiteboard •  - Distractions •  Ask: “How would this work in an ideal world?”

Slide 24

Slide 24 text

The New Solution:

Slide 25

Slide 25 text

The Power of Quad Programming

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

A Brand New Bridge!

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

How to use it Gemfile: gem ‘salesforce_ar_sync’ Routes.rb: MySampleApp::Application.routes.draw do mount SalesforceArSync::Engine => '/integration' end

Slide 31

Slide 31 text

Salesforce to Rails via outbound messaging

Slide 32

Slide 32 text

Outbound Message Setup Screen

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

Mapping class Contact < ActiveRecord::Base salesforce_syncable :sync_attributes => { :FirstName => :first_name, :LastName=> :last_name, :AccountId => :salesforce_account_id } end

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

Constraints •  Rails 3.1+ •  Built in dependency on delayed jobs. •  Deletes from Salesforce •  Contact & Lead merges •  Async attribute syncing

Slide 37

Slide 37 text

Sample App •  Sample rails app with gem •  Deployable to Heroku http://github.com/infotech/sf_sync_demo

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

No content