Monday, June 15, 2015

Setting Up Lightning Connect in Salesforce

Salesforce Lightning Connect
Now it's time for the fun part of trying to get Microsoft Dynamics AX 2012 data into Salesforce.  My previous post covered the details of setting up the OData Service In Dyanmics AX.  With an external, https URL to our Dynamics demo environment in hand, it only takes a couple of clicks, and no code, to setup the connection.

External Data Source

First an external data source needs to be setup in Salesforce.  This is done from Setup with the following steps.  If you would like to learn more on Lightning, check out the Lightning Webinar Series.
  • Go to Setup | Develop | External Data Sources and click New Data Source.
  • Provide a label and a name.  I used DynamicsAX for both values
  • From Type, select Lightning Connect: OData 2.0
    • Take note of the 2.0, as this is the minimum OData version that Lightning Connect supports
    • There may additional options, especially if in a Summer '15 or higher org, which introduced the ability to create Lightning Connect Custom Adapters
  • After selecting this option, additional Parameters are available
    • URL - the Dynamics OData Source in the form of https://<host>.<domain>:8101/DynamicsAx/Services/ODataQueryService/
    • A series of options, which the default values are okay
    • Format - our source is AtomPub
    • Special Compatibility - Default is appropriate
  • Authentication details for our source must be specified
    • Identity Type - Name Principal to specify a static username/password to Dynamics AX
    • Authentication Protocol - Password Authentication
      • Supply the Username and Password to use to connect
      • As we are providing credentials, our URL must be https
  • After Saving, there is an option to Validate and Sync
    • Salesforce has made quite a few improvements between Spring '15 and Summer '15 in this area. 
      • When testing in Spring '15, I had cases where no error messages were displayed or only generic messages.  
      • After the Summer upgrade, I saw more consistent messages with additional details to help troubleshoot.
    • Ensure you have a valid SSL certificate, or you will not be able to validate and sync
  • A list of OData tables is presented to sync.  In my case, I selected ListofUSStates.  This is a simple listing of the US States and Names used in Dynamics. 

External Objects

    Now, the selected External Objects can be modified.  In order to make the object more useful within Salesforce, a few properties can be adjusted.  A meaningful label, like US State and plural version can be specified.  I kept the other options at default values until I proved out the concept.

    Custom Tab

    The only task standing in the way of viewing the Dynamics AX data is creating a custom tab to view the list of records.  Go to Setup | Create | Tabs and click New.  From the Object tab, select US States, pick a Tab Style.  Select the Profiles to show the tab in as well as the app. Save the new tab and its time to see our data.

    Success…?

    Now navigate to the newly created tab.  Then, simply click Go next to the All view and voila.....wait a minute what is this error message?
    Here is another case where I received more detailed error messages with Summer ‘15.  Spring ‘15 simply told me there was an error and to contact my admin.  The DataServiceProtocolVersion of v1 does not look promising, time for some more research.

    We Have a Problem

    First stop, was OData.org to check out the spec.  DataServiceVersion is defined in the Service Metadata Document and indicates the version of OData used.  So now to inspect the metadata for our Dynamics AX source.  This can be done by adding /$metadata to the end of our base URL.
    metadata
    Hmm…DataServiceVersion = “1.0”, which does not look good.  Let’s try a few of the OData URI Conventions that should be supported like $select to specify columns to return. This can be done by adding ?$select=<column> name to the end of the ListOfUSState URL - https://<host>.<domain>:8101/DynamicsAx/Services/ODataQueryService/ListofUSStates?$select=LogisticsAddressState_1_Name.  Unfortunately, we run into the same error as before.
    error2

    Conclusion

    At this point, I am reasonably certain Dynamics AX 2012 is OData version 1.0 and Lightning Connect requires 2.0.  Just to leave no stone uncovered, time to call in the big guns and verify with Salesforce Product Management.  After taking a look at my setup, they reached the same conclusion that Dynamics AX 2012’s OData 1.0 version was not supported.

    What I did learn from the Product Management team is that Summer ‘15 loosened some of the restrictions on OData 1.0 implementations.  Rather than immediately excluding the service based on the version, Lightning Connect will attempt to use the service. Only if the service does not support the necessary conventions, like $select, will it fail.  This can be useful in cases where DataServiceVersion is not specified, as the OData spec indicates that version 1.0 should be assumed.

    While I did not end up with Dynamics data available in Salesforce via Lightning Connect, I did learn a lot along the way.  Once you have an OData source available, setup in Salesforce is fast and easy.  I am looking forward to the next attempt to use Lightning Connect.  Besides, there are a lot of other ways to get Dynamics data into Salesforce.

    No comments:

    Post a Comment