Introduction

In this article, I would like to walk through a typical Salesforce scenario using Logic App. The scenario is, a notification will be sent to Logic App from Salesforce System when there is an opportunity updated with ‘Closed Won’ stage.

In this sample, I have used SOAP API so it required to have a Function App for the conversion of XML to JSON. Salesforce Rest API based connectors are available in Logic app which requires no coding or conversion.

Scenario

  • A sales representative creates an “opportunity” in the Salesforce system.
  • When the status of the opportunity is set to “Closed Won”, a notification is sent to Logic app.
  • Logic App uses the information received from Salesforce to create a purchase order entry in an in-house SQL Server database table.

Before we start the logic app we need to setup Source(Salesforce) and Destination(SQL Server On-Premise) Systems.

Salesforce Setup

  • Provide our Http URL to Salesforce so that it will post Messages whenever the condition is met.
  • Salesforce SOAP Message would look like,

9

SQL Setup On-Premise

Once we receive the request, we split the Opportunities to the below stored procedure which inserts a row local on-premise table.

2.PNG

On-Premise Data Gateway

Once we create the table in the on-premise database, install the “on-premises data gateway” and configure it.

here is an article could help you to setup with "on-premises data gateway".

Logic App

11

This logic app receives the notification, converts into Json message and then it calls the on-premise stored procedure for each notification.

Once we receive the notification, I use an Azure function which removes the namespace of the received SOAP message and converts into JSON formatted message. Below is my function app call. 

12

Function App 

13.PNG

After receiving the JSON request from Logic App, out function app fetches the XML part and removes all the namespace out of it. Then the plain XML part is being converted into JSON formatted message and sent back to Logic App.After receiving the JSON format from XMLTOJson function app, using parse JSON shape, I am creating a JSON request.

14.PNG

Now we need to loop through notification request message and call on-premise stored procedure to insert the data into On-premise table.

15.PNG

In the code view it would look like the below(the below view is from Chrome json editor,

To run this program we could use Postman, also once all done this Logic app we could update any opportunity in Salesforce as “Closed Won” stage, so that a notification will be sent to Logic App.

16.PNG

Successful Run,

17.PNG

If your stored procedure is not reachable then try restarting your “On-premises data gateway service”service in your local machine and start connecting through “On-premises data gateway” UI.

Here is my Salesforce data in Customer table on-premise.

18.PNG