2

I'm building an external application and trying to get notifications from Salesforce when "standard" objects have changed. For example: when an opportunity statues was changed to "closed won".

I am having a hard time understanding which APIs I would use. I tried to use the streaming API but it seems there are definitions such as channels (for CDC) or PushTopics that need to be defined on the salesforce end (meaning my customers will need to go into their Salesforce setup and tinker with stuff which I really prefer to avoid and minimize).

As an example, if I connect a service like Zapier to my Salesforce instance, I can easily get notified when an opportunity's status has changed. I don't need to do anything on my Salesforce instance to get this done.

What API calls should I use to achieve that?

3
  • Are you specifically looking to use Zapier or something else (custom code receiver, Mulesoft, etc.)? Nov 29 '21 at 18:25
  • The architectural options are well covered in Integration Patterns and Data Integration. Depending on the integration approach chosen, your next step would be to check if your chosen product (e.g. Zapier) supports it.
    – identigral
    Nov 29 '21 at 18:34
  • @VictorLockwood I used Zapier as an example of a service that seamlessly connects to SF and can execute stuff based on things that change in SF. I would like to build a similar flow in my app, not to use Zapier
    – nick
    Nov 29 '21 at 22:53
3

CDC requires some setup, but you can do this with the Tooling API or Metadata API fairly trivially. However, CDC is more of a replication feature (e.g. you'll get all updates, not just those you're interested in), so it will require more resources than strictly necessary. PushTopic allows you to specify a query, which you can create via the SOAP or REST API. There is no need to define the PushTopic in the UI before you can use it. Either way, no additional setup is required by a subscriber. Once you have a valid Session ID to use (e.g. with OAuth2 login flows), the subscriber doesn't need to do anything "extra" or "manually."

4
  • That being said, when an app such as Zapier, connects to Salesforce using the OAuth 2.0 authorization flow it will use the access token obtained to call Salesforce APIs. This might be your scenario, where you want your end-user to authorize your app to connect to Salesforce. From there, you can get their token to access Salesforce's REST API and create the PushTopics. Nov 29 '21 at 18:02
  • 1
    On the Salesforce side, CDC at the very least needs you to enable it for the entities you want - if I don't stick Account in the Selected Entities column on the setup page, I'm not going to be able to get anything about Account change events. As far as the application side is concerned, it can be a real pain (custom code subscriber) or really easy (middleware like Mulesoft) to subscribe to a channel, all depending on your application - OP isn't clear if they're using Zapier or if it's just an example. I think saying 'CDC requires no setup' is oversimplifying it. Nov 29 '21 at 18:23
  • 1
    @VictorLockwood Hmm, I must have missed that. That said, there is an API for that; again, no need to get into the UI (but, obviously, only admins can call this API).
    – sfdcfox
    Nov 29 '21 at 18:27
  • Good to know there's an API for that actually - that'll likely be handy in the future for my team's needs. Nov 29 '21 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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