Web hook in salesforce?

痞子三分冷 提交于 2020-01-12 02:58:08

问题


I want to get notified when a new lead is created in Salesforce. Is there something like webhook in Salesforce or some other way to achieve this ?

Any help is appreciated


回答1:


Yes, plenty of options :)

For SF as actor:

  1. Workflow rule that would fire on insert of Lead and send you an email (or if it's for system integration - outbound message).
  2. You can always write an "after insert" Apex trigger and have in it a callout to external system (SOAP and RESTful APIs are supported). Although you'll need an extra @future trick because the triggers by default aren't supposed to send callouts (the database commit/rollback shouldn't depend on whether the external system has accepted the message or not).

For external system as actor:

  1. Simply poll every once in a while for something like [SELECT Id FROM Lead WHERE CreatedDate > :lastTimeIhaveChecked]
  2. Or there's fairly recent addition called Streaming API. Basically you define a PushTopic (query that interests you). Salesforce peeks at the current results returned by it and whenever the results change you'll get a notification. I haven't played with it yet but seems from the docs you can set event type to show "created" events only. This might be closest to a webhook.



回答2:


I hate to self-promote but since some might fine this as a useful answer... I built a Webhook creator for Salesforce. It is open source: https://github.com/jamesward/salesforce-webhook-creator




回答3:


This usually involves writing your own code to "subscribe to" events, construct a message and send it to an external endpoint. I have written quite extensively on this topic at: http://beachmonks.com/posts/integrations/salesforce/practical-guide.html. The source code is at: http://github.com/beachmonks/choir-salesforce.




回答4:


SalesForce does support webhooks, they are just called by a different name - Callouts.

Here's a link to the Developer documentation on the topic:

Invoking Callouts Using Apex

Here's a description of the feature taken directly from the link above:

An Apex callout enables you to tightly integrate your Apex with an external service by making a call to an external Web service or sending a HTTP request from Apex code and then receiving the response. Apex provides integration with Web services that utilize SOAP and WSDL, or HTTP services (RESTful services).

That is pretty much what webhooks do.




回答5:


There is another way. Use RoundRobin logic to assign new incoming leads. Then create a new WF rule to send notification to new owners plus Admin or who ever else wanted to be notified.



来源:https://stackoverflow.com/questions/13121688/web-hook-in-salesforce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!