Monday, January 9, 2017

Using Logic Apps to create records in Dynamics 365 - Part 1

According to Microsoft documentation, Logic Apps is a service to simplify and implement scalable integration and workflows in the cloud. As a CRM professional I was aware of Microsoft Flow but not of Logic Apps. Microsoft Flow is actually built on Logic App Most of the features and API connections are the same.

The major difference is that Microsoft Flow is targeted for business users whereas Logic Apps is targeted towards IT professionals and developers. Logic Apps can have some additional connections like BizTalk APIs. The other major difference is that Microsoft Flow workflows are created in production but Logic Apps provides the DevOps and security assurance.

The following link details the comparisons between Microsoft Flow and Logic Apps
https://docs.microsoft.com/en-us/azure/azure-functions/functions-compare-logic-apps-ms-flow-webjobs#flow-vs-logic-apps
For this Blog I am building a Logic App that will act as endpoints to create records in Dynamics 365. The good thing is that we don’t need to write code to create the endpoints.

Create a Logic App

  1. Logon to the Microsoft Azure Portal.
  2. Create a new Logic App by Navigating to New>>Web +Mobile>>Logic App as shown in the screen shot below.

    2017-01-05_16-01-49
  3. Enter the app name and other information as required and click Create. (I generally checked “Pin to Dashboard” to open the app straight from the dashboard)

    2017-01-05_16-05-45
  4. Open the newly created app.

    2017-01-09_21-37-24
  5. Click on Edit to open the designer.

    image
  6. Select Request from the list of the managed APIs as shown in the screen shot.

    2017-01-07_22-35-44
  7. Enter the JSON schema for the request. I have created a customer object with first name, last name, street address and city.

    2017-01-08_17-41-31
  8. Click Save. It will populate the URL field of the request. This URL will be used as endpoints to call the Logic App.
  9. Click New step and choose Add an action.

    2017-01-08_17-44-13
  10. Select Dynamics 365 – Create a new record from the managed APIs list.

    2017-01-08_17-46-17
  11. Choose the Organisation Name, choose the Contacts as the entity name and map the first name, last name, street address and city with the JSON schema added in step 7.

    2017-01-08_17-47-52
  12. Click New step and choose Add an action as shown in the screen shot below.

    2017-01-08_17-49-19
  13. Select Response from the list.
  14. Enter the following information as shown in the screen shot below
    • Status Code of 200 (Which represents successful call).
    • Enter the “content-type” in the Headers section.
    • Enter the JSON in the body section. I am returning the contactid of the newly created contact.2017-01-08_17-52-28
  15. Save the app and test it.

Testing the Logic App

For testing we need to call Logic App using URL created for Request step 8 of Create a Logic App.

2017-01-09_22-31-29

For this blog, I am not creating a new application to call the endpoints(Logic App). I am using PostMan to create and send the request. Here are the steps.

  1. Open the PostMan application.

    2017-01-09_22-38-28
  2. Enter the URL copied from the Request.
  3. Enter the Headers as shown in the screen shot below. The endpoints are expecting JSON.

    2017-01-09_22-43-28
  4. Enter the Body and Click Send. The  Logic App will return the customer id as shown in the screen shot below.

    2017-01-09_22-50-39
  5. Open the CRM and check the contact is created.
  6. If there is an error, go to Azure portal and look the app summary and troubleshoot the error.

    2017-01-09_22-56-07


That is it . You got your Logic App as callable endpoints.

 

2 comments:

  1. can I create a record in dynamics 365 from mobile app using Microsoft logic app

    ReplyDelete
  2. Hi sir,

    Nice Explain sir, but i have error is coming when i create http request .

    my code:{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties":{
    "customer":{
    "type" : "object",
    "properties": {
    "firstName": {
    "type": "string"
    },
    "lastName" : {
    "type": "string"
    } ,
    }
    }

    }
    }

    please help me sir

    ReplyDelete