Outbound message in Salesforce : Gaurav Jain

Outbound message in Salesforce
by: Gaurav Jain
blow post content copied from  Apex Hours
click here to view original post

Workflow Outbound message can be used to connect or pass the data from Salesforce to any other external system using SOAP API. In the form of SOAP API notification a single SOAP message can include up to 100 notifications.

Outbound messaging is part of the workflow rule functionality in Salesforce. Workflow rules watch for specific kinds of field changes and trigger automatic Salesforce actions, such as sending email alerts, creating task records, or sending an outbound message.

If the message from the other API (3rd party listening API to be precise 😊) is “NOT OK” i.e. if the message failed to get delivered, then Salesforce will try again and again within 24 hrs. The frequency of trying again will keep decreasing based as the attempts increases and it keep getting failed. Salesforce rely on an XML response from the 3rd party in a particular format and with a particular value in XML to determine the success or failure of delivery of message.

Use Case of Outbound message

One common use case to use workflow outbound message is, to sync any 3rd party system when an account record is created in Salesforce or a lead is converted in Salesforce etc.

To demo any of the above scenario for outbound message first, we need to create an endpoint. Since creating endpoint is outside of the scope of this article, so I have used a free online tool, which can help us to create a temporary endpoint to receive and test out request. 

There are many online tools available for it, but I have used hookbin.com for the same. Please remember all these online tools do not return acknowledgement back to Salesforce once the message is received at other end. That forces Salesforce to consider that message was not delivered successfully, and Salesforce will keep trying to send again.

I have created an endpoint https://hookb.in/zroJbnrKBNfykkGKwoMj

Setup Outbound Message

As explained above our use case is, we need to send the account information to a 3rd party API immediately an account is created in Salesforce. 

  • Set up -> workflow rule
  • Select an object for which you want this workflow to apply. For this demo, I have selected Account object. 
  • You can also set the rule criteria if any. But for this article, we are keeping in simple and only criteria is, account name should not be blank.
  • In the next step, add the workflow action. In this case, it will be “New outbound message”.  
  • Provide all the required details as below. Few important things are, what fields do you want to send, do you also want to send session id with your request etc.
  • Final step is to activate the workflow rule. 

We are done now. 

Test outbound Message in Salesforce

Let’s test it out create an account and test that whether endpoint receive the data. 

Check status of outbound message here (setup->outbound message). It shows the failed message and salesforce keep trying to resend the failed message until 24 hrs. and after that it drop the message from queue.

Something to note here is, Salesforce only understands that message is successfully delivered at the other end by receiving the acknowledgment. If ACK is not received, then message is considered as not delivered and salesforce keep trying it to resend. 

For the endpoint (hookbin.com) which I used earlier , it does not return acknowledgement therefore even if at the API end (hookbin.com) you will be able to see the data is successfully received but in salesforce, it will keep appearing as failed message when you open monitor tool in outbound message. 

To better explain the success acknowledgement, I have used herokuapp for the same.

You can use Heroku and Salesforce platform for several different type of integrations and you can read about Heroku platform here https://devcenter.heroku.com/articles/integrating-heroku-and-salesforce

Direct link for WF integration with Heroku, you can directly use – 

 http://intg-playground.herokuapp.com/sfdc/omlistener link. 

Recording of Session

If you are new in Salesforce. Please check our free Salesforce Admin and Salesforce Developer training.

Further Learning

The post Outbound message in Salesforce appeared first on Apex Hours.

February 04, 2021 at 05:31PM
Click here for more details...

The original post is available in Apex Hours by Gaurav Jain
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.