Showing posts with label Dynamics 365. Show all posts
Showing posts with label Dynamics 365. Show all posts

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.

 

Tuesday, December 13, 2016

Adding Icons and Tooltips to grid columns in Dynamics 365


I was going through the “What’s New” section of the Dynamics 365 SDK and found out that you can now add icons and tool tips to the grid view columns.
Microsoft has added the 2 imageproviderwebresource and imageproviderfunctionname to the layout xml of the <cell> attribute of the saved query. These fields can be used to attach a web resource and JavaScript function that will display the icon and the tooltip.
For this blog, I am displaying red, yellow and green light bulbs based on the priority of the case.
Here are the steps:

Create 3 Icon web resources

  • Find 3 icon/image files for red, green and yellow color. I am using PNG files of size 16x16 pixel for this example.
  • Create a new web resource of type “PNG Format” as shown in the screen shot below.

    2016-12-13_16-04-47
  • Repeat the above step for green and yellow icons.

Create a JavaScript web resource

Create a JavaScript web resource with the following function. It is the same function that is used in SDK sample. The function takes the 2 parameters rawdata and userLCID. The userLCID can be used to display the tip in different languages. Check the SDK example for details. https://msdn.microsoft.com/en-us/library/gg328457.aspx#BKMK_CustomIcons. In this example I am not using userLCID as only default English language is installed in my CRM.
 //display icon and tooltio for the grid column  
 function displayIconTooltip(rowData, userLCID) {  
   var str = JSON.parse(rowData);  
   var coldata = str.prioritycode_Value;  
   var imgName = "";  
   var tooltip = "";  
   switch (coldata) {  
     case 1:  
       imgName = "new_/images/red.png";  
       tooltip = "High Priority Case";  
       break;  
     case 2:  
       imgName = "new_/images/yellow.png";  
       tooltip = "Noraml Priority Case";  
       break;  
     case 3:  
       imgName = "new_/images/green.png";  
       tooltip = "Low Priority Case";  
       break;  
     default:  
       imgName = "";  
       tooltip = "";  
       break;  
   }  
   var resultarray = [imgName, tooltip];  
   return resultarray;  
 }  

Attaching JavaScript web resource to the view column

  • Open the view for which you would like to display the icons and tooltips. For this example, I am using “My Active Cases”.
  • Select the column Priority and click on “Change Properties”

    2016-12-13_16-23-09
  • Specify the JavaScript web resource and function name.

    2016-12-13_16-25-30

Results

Publish all the customizations completed in the above step. Navigate to “My Active cases” and check the results. You will notice different color icons based on the priority of the case.

2016-12-13_16-46-25