1

We want to develop an application that would monitor other companies/people Salesforce sandbox/production instances and produce notifications about some changes that happen there (user configures what he wants to be notified about). For example, user wants to be notified whenever an Account is removed from his instance.

I understand this is possible by REST API and that was our initial approach. Bottom line is: user defines what he wants to be informed about in our app we create a monitor and we use some interval based rest call to salesforce inside it with a specialized query (f.e SELECT Name, [other fields user wants to see] FROM Opportunity WHERE LastModifiedDate > start AND LastModifiedDate <= end.

The WHERE clause changes because of interval, thus allowing us to have constant monitoring over customer instance. That of course has a drawback that it uses a lot of API calls, and because its interval based, it is not instant (its delayed depending how long interval is). The other thing is we don't have any information about how the data looked before change (access to history), we only see what is in Salesforce at a moment of making a call (this is important for updates).

We started to wonder if there aren't any other ways of handling that problem (monitoring customer salesforce orgs). We aim towards having instant notifications and maximal availability (among as many editions as possible).

I have noticed that it is possible to create ApexTriggers(https://xxx.salesforce.com/services/data/v32.0/sobjects/ApexClass) and ApexClasses through REST API as well. I was thinking that maybe I could generate such Trigger/Class and add it to customer Salesforce instance, and then it would have a callback to our application with the data. This would give us instant notifications and would not eat away API calls as well as let us see history. I managed to create such trigger class and get it working. The flow is user configures his monitor on our app side, we make REST call to add trigger to his instance. When the trigger is 'triggered' it calls back our app endpoint with data.

Only obstacle I see now is Remote Site Settings, since the endpoint I'm making callbacks to from trigger has to be added there. Is there a way to add it without involving Salesforce user (customer)? We want to avoid manual steps to have an easy customer experience.

I'm also wondering if there aren't any more obstacles, like limitations of actual different salesforce editions that would make my idea invalid in some way or anything else really that I'm not seeing (it is an ongoing learning process). I also am not sure if I can create Apex Classes on production instances.

We don't want to create an App that is build into Salesforce using appexchange (and go through all that approval process). We want to connect to users Salesforce instance (authentication through OUATH) and get some data from there, but we want to do it in a smart way, so not eat API calls when its not needed (so theoretically put triggers on SF to inform us when something happens instead of making calls all the time).

To put it shortly: We want to react on changes, see what changed to what and have this data reliably and fast without making unnecessary calls.

What do you think about both approaches, which would you use and why or is there anything else I need to keep in mind (limitations)? Are there any other approaches you would choose? Any help with this is greatly appreciated. Sorry for a long question, I wanted to explain the problem as detailed as possible.

1 Answer 1

0

Would the streaming API not be useful for your case? "Use Streaming API to receive notifications for changes to Salesforce data that match a SOQL query you define, in a secure and scalable way.

These events can be received by:

  • Pages in the Salesforce application.
  • Application servers outside of Salesforce.
  • Clients outside the Salesforce application.

The sequence of events when using Streaming API is as follows:

  1. Create a PushTopic based on a SOQL query. This defines the channel.
  2. Clients subscribe to the channel.
  3. A record is created, updated, deleted, or undeleted (an event occurs). The changes to that record are evaluated.
  4. If the record changes match the criteria of the PushTopic query, a notification is generated by the server and received by the subscribed clients.

Streaming API is useful when you want notifications to be pushed from the server to the client based on criteria that you define. 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."

https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/

1
  • I have considered Streaming API some time ago and I was quickly discouraged. It seems as something that would work for us but it has too many limitations and drawbacks to use in our app, mainly it is advertised as unreliable which we cannot simply accept at all. The other problems are mentioned limits as well as the fact that that the Api needs to be enabled to actually work, which is a manual step for a customer which we dont want to have.
    – Raidmaster
    Commented Jun 30, 2015 at 16:31

You must log in to answer this question.

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