4

I've successfully got the .NET c# toolkit running and I can talk with API by posting queries and getting accounts, cases etc. printed, which is very nice. This is what I want to achieve:

  • When a user sets Opportunity -> StageName to "Closed Won" using the website Salesforce, I want Salesforce to message my C# program about the change. From the C# program I run a query with the AccountId, fetch the cases of the Opportunity and save a set of attributes to variables and send these off to a a table in a database.

My problem is how to make Salesforce talk to my program. Is this possible?

I have read that you can send an outgoing message to an URL when a certain action happens in Salesforce - is this what I am looking for?

3 Answers 3

4

Yes, you'll want to read Setting Up Outbound Messaging for more info. Basically, you set up a workflow rule that triggers when the record is Closed Won, then Salesforce will send a SOAP-based message to the specified endpoint. The message includes a session ID so you can call the API while processing the message.

2

You can use a callout in your trigger (conditions apply, read: HTTP Callout from Triggers), to send data to a external server, which you can host your c# code on. Its unlikely that theres any method which you can use to call external programs from Salesforce without hosting that program on a publicly accessible server.

It would likely be easier for you to set a flag on those fields in your trigger, say Export_Record__c, and every ~15 minutes, have your c# program query for any records with that flag, and move those records to an external database, then unset the flag.

2

Outbound messages or a trigger based callout are common solutions based on you hosting a web service for Salesforce to callout to when something changes.

Another option is the Streaming API. With this you create a PushTopic based on a SOQL query to define a channel. When an event occurs that matches your PushTopic a notification is sent to all channel subscribers.

Consider the following applications for Streaming API:

Applications that poll frequently
Applications that have constant polling action against the Salesforce infrastructure, consuming unnecessary API calls and processing time, would benefit from Streaming API which reduces the number of requests that return no data.

General notification
Use Streaming API for applications that require general notification of data changes in an organization. This enables you to reduce the number of API calls and improve performance.

Getting the Bayeux Protocol and CometD to work from .NET can be a bit of an exercise, but it is an option.

Also, keep an eye on the Platform Events Beta that came out in Spring '17.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .