PutsReq With Outbound Messages

In order to eliminate multiple server calls for a single record, a new feature has been introduced in Winter’17 called Lightning Data Service (LDS) with the developer preview of force:recordPreview component.

Outbound Message feature is used to send data from Salesforce to the other systems based on workflow or approval process. SOAP messages can be sent to external systems using this action while integrating Salesforce with other systems. Using PutsReq, which is used to record HTTP requests and fake responses, we can test the Outbound Message. For example, we have configured workflow rule and the outbound message, and we would want to make sure that outbound message is triggered after meeting the workflow evaluation criteria and rule criteria. We can even test format and structure of the message being sent. It is advisable to test the outbound message and what payload has been delivered to the external system.

PutsReq allows us to create a service which will have our outbound message, display request headers, and body, and send salesforce a successful acknowledgment receipt. Other API monitoring tools like RequestBin and Runscope can be used for testing purpose. In case of Request Bin, it cannot return an acknowledgment back to Salesforce on the receipt of the outbound message and Salesforce will keep resending the outbound message for the next 24 hours.

Steps to Configure PutsReq in Outbound Message: 

1. PutsReq setup and creating Bucket: 

We can setup putsreq bucket as the service and can make use of that as the endpoint URL in the Salesforce outbound message. Below are the necessary steps to be followed:

  1. Navigate to http://putsreq.com and click “Create a PutsReq” button.
  2. In the response builder, add the SOAP response for the acknowledgement. This is used to make an acknowledgment to Salesforce regarding successful delivery of the outbound message that we send.
  3. Click the “Update” button to update the response builder.
  4. Note down the “your PutsReq URL”, which can be used as the Endpoint URL in the outbound message.
putsreq

Fig. 1: PutsReq setup. 

Response Builder code: 

Below is the code for the Response Builder to send the response for the corresponding outbound message in JavaScript for PutsReq service to the Salesforce after successfully receiving the outbound message.

var msg;

msg = ‘<soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/”>’;

msg += ‘<soapenv:Body>’;

msg += ‘<notificationsResponse xmlns=”http://soap.sforce.com/2005/09/outbound”>’;

msg += ‘<Ack>true</Ack>’;

msg += ‘</notificationsResponse>’;

msg += ‘</soapenv:Body>’;

msg += ‘</soapenv:Envelope>’;

response.body = msg;

2. Configure the Outbound Message:  

After setting up the putsreq and the URL for the endpoint, we can create Outbound message back in the Salesforce. Create a Workflow that triggers on contact when the first name of the corresponding contact is empty. Once the workflow is created with necessary evaluation criteria and rule criteria, add a new outbound message workflow action. Configure the Outbound Message with the EndPoint URL which is nothing but “Your PutsReq URL” from the PutsReq and add required fields that outbound message should send in the SOAP message.

putsreq

Fig. 2: Outbound Message Setup with PutsReq URL. 

3. Remote Site setting: 

After creating workflow with outbound message, remote site setting can be created in order to make a call to an external endpoint.

  1. Navigate to Remote site settings from setup[Symbol]Security Controls.
  2. Let the Remote Site URL be: http://putsreq.com.
  3. Check Disable Protocol Security – Since PutsReq is http, and for https it can be unchecked.
  4. Activate and Save.
putsreq

Fig. 3: Remote Site setup. 

4. Testing in PutsReq: 

After setting up PutsReq, workflow with outbound message, and remote site settings we can test outbound message. Create or modify a record by satisfying the workflow rule criteria to trigger the corresponding Outbound Message.

PutsReq will display request headers, request body, and the response body which the PutsReq sent back to Salesforce as a response.

putsreq

Fig. 4: Outbound Message sent to PutsReq. 

Above Fig 4 shows the outbound message sent from the Salesforce to the external system, by using putsreq which used to record fake responses from Salesforce. In the above outbound message it contains organization Id, session Id, Enterprise URL, record ID, and the fields which mentioned in the outbound message setup.

putsreq

Fig. 5: Response sent to the Salesforce as an acknowledgement. 

In the above Fig. 5, it shows the response sent back to the Salesforce after receiving Outbound Message successfully. This response code can be explicitly added in the Response builder as mentioned in the Step 1: setting up PutsReq and creating bucket.

Considerations: 

  1. If the putsreq endpoint is unavailable, messages will stay in the queue.
  2. Acknowledgement is sent to the Salesforce to avoid repetition in sending the same message.
  3. When the messages aren’t delivered, it retries to send independent of their order in queue.

Benefits: 

  1. Response is sent to the Salesforce after receiving outbound message successfully
  2. Only one acknowledgement is sent for the bulk update.
  3. Ease of access to the information from the outbound message.

Reference:  

About MST

At MST Solutions our cornerstone is to adapt, engage and create solutions which guarantee the success of our clients. The talent of our team and experiences in varied business verticals gives us an advantage over other competitors.

Recent Articles

Work with us.

Our people aren’t just employees, they are key to the success of our business. We recognize the strengths of each individual and allow them time and resources to further develop those skills, crafting a culture of leaders who are passionate about where they are going within our organization.