Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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

share|improve this question
    
The salesforce integration may provide some direction (look for data integration) : wiki.developerforce.com/page/Integration –  Samuel De Rycke Feb 17 at 22:52

2 Answers 2

up vote 6 down vote accepted

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.

share|improve this answer
    
Hi @Andrew, thanks a lot for such a detailed reply. much appreciated. My application is a web application build in asp.net mvc and c#. Is the replication API method good for multiple users trying to sync the data simultaneously? 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" ? can we add new fields to the existing objects like contacts etc? –  mani Feb 18 at 5:05
    
I have updated my answer to cover your additional questions, hope this helps. –  Andrew Fawcett Feb 18 at 8:13
    
Thanks a lot !!! –  mani Feb 18 at 20:31
    
Your most welcome @mani :-) Also if you found this answer acceptable please feel free mark it as such. –  Andrew Fawcett Feb 19 at 10:05
    
Nice detailed explanation on various salesforce data sync methods. Are there any limits on polling with the data replication api? I didn't find any in documentation. Also any comments on the inefficiencies of constant polling from the client side? –  Andy Dufresne Dec 15 at 12:14

This might be a tough question to answer completely, but I'll give you some thoughts to get things started:

  1. Connecting to the Salesforce Streaming API might not be straight forward. I've had a quick look in the past and I'm not sure you can get an off the shelf solution that works with CometD in .NET the way Salesforce wants to.
  2. I have successfully used outbound messages to a .NET web service to push notifications from Salesforce into an external system.
  3. Careful consideration will be required to prevent update loops. You don't want an update from Salesforce in .NET sending the change back to Salesforce. You can prevent Salesforce from sending outbound messages with updates from .NET by having a special API user that doesn't have permissions to send the messages.
  4. You might want to consider avoiding synchronization completely and just using one system as the authoritative source of information. I.e. Just store all the information in Salesforce and pull it into the .NET system as required. I've had great success with this in the Sitecore CMS. You need to add a layer of caching, but you skip over a large number of synchronization issues.
share|improve this answer
    
Hi @Daniel thanks a lot for your reply. i have some more queries (1) with the help of outbound messages, can we insert/update multiple objects( for example account, contact, opportunity etc)? (2)could you elaborate further what steps will be required for outbound technique ? do u have any sample code. (3) how will i install my coding for all the salesforce user of my application? (4) is it possible if i use our application's database as the source of information and just showing the User interface at salesforce? –  mani Feb 18 at 4:56
    
Also with the outbound messages 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" ? can we add new fields to the existing objects like contacts etc? –  mani Feb 18 at 5:08
    
Hi @Daniel, Could you please answer above questions. –  mani Feb 19 at 2:55
    
@mani For something like pulling data into Salesforce from a button click I'd use Apex in a controller class to call an imported SOAP WSDL or a REST API. You can also use an outbound message to then push data back to Salesforce using the Session ID and Server URL, but this is less common. –  Daniel Ballinger Feb 19 at 7:37
    
thanks a lot @daniel –  mani Feb 20 at 23:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.