[SalesForce] Real time updates – Streaming API vs workflow Outbound messages

My organization has a requirement that if anything is updated/inserted in our web application (cloud based application built in ASP.net and c#) that it should be automatically be updated in SFDC and vice versa.

There are 1000 of users in our website and they have their account in salesforce too. Now to sync the data between these two some real time automatic updates are required. Also whenever a new user logs in we should not have to do any coding again.

-How can we synchronize their data between sfdc and our application?
-Can we show the real time automatic updates?

Could anyone please let me know the steps to build such interface within salesforce?

I read about Streaming API and workflow outbound messages, but i am unable to figure out which approach is best, so could anyone please let me know which approach is best and why? and if there is any other method apart from these, please let me know

our main requirement is to do a real time and/or on-demand push and pull from my application's db.

thanks in advance.
marilyn

Best Answer

Web Application to Salesforce

You don't state the technology your web application is built with, however the Salesforce REST and SOAP API's provide a full CRUD based API to the data in Salesforce, such that you can use these API's to callout from the appropriate place in your code.

Salesforce to Web Application

The Salesforce Streaming API is not ideal for your requirements since Salesforce cannot guarantee delivery, the following extract from the documentation confirms this.

Streaming API doesn’t guarantee durability and reliable delivery of notifications. Streaming servers don’t maintain any client state and don’t keep track of what’s delivered. The client may not receive messages for a variety of reasons

Outbound Messages are linked with the Workflow engine, which only covers insert and update, not delete. They are more real time, though some conditions exist where messages can be dropped, see the Understanding Notifications subsection for more details.

The most reliable way that i have read about, which is actually designed for your use case is the Replication API. Though this is not real time however, though it does give access to records created, updated and deleted within the last polled time frame. You could run a service in your web application to periodically make these replication API calls.

The API supports data replication, which allows you to store and maintain a local, separate copy of your organization’s pertinent Salesforce data for specialized uses, such as data warehousing, data mining, custom reporting, analytics, and integration with other applications. Data replication provides you with local control and the ability to run large or ad hoc analytical queries across the entire data set without transmitting all that data across the network.

Note that Apex supports HTTP callouts to REST/SOAP API's on external servers, such that you might think Apex Triggers (called at the db level) can be used. However the HTTP callouts cannot be made from this context. Requiring the use of Async Apex, this in itself presents reliability issues (what happens if your web service fails?).

Finally you could consider overriding the UI for the Account entry with a Visualforce page and thus make the HTTP callout from an Apex Controller. However this option does not actually help if Accounts are created or updated from the Salesforce API or via the native UI, however if either of these routes can be excluded from the requirements this might be your best bet.

You may also find this question and answer a useful read, What is the best approach to call a webservice from SFDC?.

Additional Questions

Q: Is the replication API method good for multiple users trying to sync the data simultaneously?

A: The API will only return records that are visible to the user the API is logged in as, so make sure your API user has enough privileges to see the records you want to replication.

Q: Can a salesforce user invoke changes ? i mean can the changes be brought from my application's db by clicking on any button like "get changes from my application" ?

A: If your Web Application exposed a REST/SOAP API you could call this from a Custom Button in Salesforce to accomplish this. However this is a code solution, you there is no built in button to do this.

Q: Can we add new fields to the existing objects like contacts etc?

A: Yes you can, it is a key feature of Salesforce, the ability extending existing objects with custom fields.

Related Topic