If you need to expose a custom table in Microsoft Dynamics AX 2012 for integration to a custom entity in Microsoft Dynamics CRM 2011, then this post is for you! Let's say that you will be creating a custom entity in Microsoft Dynamics CRM 2011 and that entity really doesn't integrate to one of the out of the box tables in Microsoft Dynamics AX 2012 or that you would like to integrate to a staging table in Microsoft Dynamics AX 2012 and then have your custom Microsoft Dynamics AX 2012 code pick up the data from that table and process it. For the purposes of this post, we will be creating a "Feature Request" entity in both systems for tracking feature requests from customers.
This post will outline how to create the table in Microsoft Dynamics AX 2012, how to create the entity in Microsoft Dynamics CRM 2011, how to expose both of those customizations to Connector for Microsoft Dynamics, and finally how to map them together. This post also assumes that you would like these records to be bi-directionally synced, that is creates and updates in either system will be reflected in the other integrated system. It should be noted that this post does NOT describe how to support the deletion of custom records in either system. Currently the integration of deletes for custom records or entities in either Microsoft Dynamics CRM or Microsoft Dynamics AX is not supported by Connector for Microsoft Dynamics. If you have already created your custom Microsoft Dynamics AX 2012 artifacts as well as your Microsoft Dynamics CRM 2011 artifacts, then you can skip to this section of this post.
This post assumes that you have the following set up and installation steps have been completed (more information on Connector for Microsoft Dynamics installation can be found in this post)
This post also assumes that you are using a user account (s) that can perform the following functions:
And finally this post assumes that you are comfortable in performing customization actions in both Microsoft Dynamics CRM 2011 and Microsoft Dynamics AX 2012 including the following:
The first step in this guide to customize Microsoft Dynamics AX to support bi-directional data integration is to determine what data you want to integrate in Microsoft Dynamics AX. For the purpose of this guide we will be creating the following components:
Component
Name
Property
Property Value
Table
FeatureRequest
CreateRecIdIndex
Yes
PrimaryIndex
ClusterIndex
ModifiedDateTime
ModifiedBy
ModifiedTransactionId
CreatedDateTime
CreatedBy
CreatedTransactionId
Fields (FeatureRequest)
FeatureId
Type
String
Label
Feature ID
Help Text
The ID of the Feature
Mandatory
StringSize
20
FeatureName
Feature Name
The Name of the Feature Being Requested
50
RequestedDate
Date
Requested Date
The Date The Feature Request Was Made
No
FeatureDescription
Feature Description
The Description of the Feature Being Requested
1000
DAXIntegrationId
GUID
Dynamics AX Integration ID
The ID Used for the Dynamics Connector AX Adapter
Index (FeatureRequest)
AllowDuplicates
Enabled
AlternateKey
Fields
Methods (FeatureRequest)
insert
Event Handler Subscription (insert of FeatureRequest)
DynConn_InsertHandler
CalledWhen
Pre
EventHandlerType
X++
Class
DynamicsConnector
Method
SetDAXIntegrationId
AOTlink
\Classes\DynamicsConnector\
Query
FeatureRequestQuery
Title
Feature Request Query
Description
Query For Feature Request Table
Data Sources (FeatureRequestQuery)
FeatureRequest_1
Update
Fields (FeatureRequest_1)
RecId
Execute the AIF Document Service Wizard to create a new Document Service.
Document Identification
Document Name
FeatureRequestDocument
Document Label
Class Names
Service Class Name
FeatureRequestDocumentService
Document Object Class Name
Axd Class Name
AxdFeatureRequestDocument
Service Operations
Create
True
Read
Delete
Find
FindKeys
GetKeys
GetChangedKeys
AxBC Generation
Generate AxBC Classes
Notes: You may need to either implement the cacheObject method or delete the cacheObject method from the AxFeatureRequest class. Also you will need to delete the cacheRecordRecord or implement that method as well from the AxFeatureRequest class.
After the wizard is complete we must expose our service via an Inbound Port. This can be done within the Microsoft Dynamics AX client in the System Administration -> Services and Application Integration Framework -> Inbound ports area. Create a new port with the following settings
PropertyValue
Port Name
FeatureRequestPort
FeatureRequestService.create
FeatureRequestService.delete
FeatureRequestService.find
FeatureRequestService.findKeys
FeatureRequestService.getChangedKeys
(this requires Microsoft SQL Server change tracking to be enabled)
FeatureRequestService.getKeys
FeatureRequestService.read
FeatureRequestService.update
Now that the Microsoft Dynamics AX side of things is customized we need to focus on the Microsoft Dynamics CRM customizations that are needed. We will need to create the following components in Microsoft Dynamics CRM
Solution
Feature Request Solution
Display name
FeatureRequestSolution
Publisher
Any Publisher Value Will Work. I created a new publisher with prefix of frsp
Version
1.0.0.0
Entity
Feature Request
Display Name
Plural Name
Feature Requests
frsp_featurerequest
Ownership
User or Team
Notes
Activities
Connections
Duplicate Detection
Primary Field Display Name
Primary Field Name
frsp_name
Maximum Length
Field (Feature Request)
frsp_requesteddate
Date and Time
Format
Date Only
Feature Id
frsp_featureid
Requirement Level
Business Required
frsp_featuredescription
Multiple Lines of Text
In order to map the custom entity in the Connector for Microsoft Dynamics client we must configure the Microsoft Dynamics CRM 2011 Adapter. This is requires executing that adapter’s configuration utility.
In order map the custom AIF document service in the Connector for Microsoft Dynamics client we must configure the Microsoft Dynamics AX 2012 Adapter. This requires executing the adapter configuration utility.
Important Note:
Due to a limitation that is currently being worked on you must change the QueryName attribute in the object provider configuration file that is generated for your Document Service. You must change the QueryName attribute from the Query your Document Service is based upon to the class name which represents your document. Usually this will be something like Axd<Class Name>. In this case it will be AxdFeatureRequestDocument.
This file can be located in %ProgramFiles(x86)%\Microsoft Dynamics\Microsoft Dynamics Adapter\Adapters\Microsoft.Dynamics.Integration.Adapters.Ax2012\ObjectConfig\<AOSServerName_DocumentPort>\
In this example the file should be called FeatureRequestPort_FeatureRequestDocumentService.config
The XML that needs to be adjusted would look like this before and after the change:
Before:
<RootDefinition Name="AxdEntity_FeatureRequest_1" TypeName="AxdEntity_FeatureRequest_1" DisplayName="Feature Request Document Service" IsRequired="false" IsReadOnly="false" QueryName="FeatureRequestQuery" ID="478ef2fe-b623-4f2f-8460-845df5720444" ServiceName="FeatureRequestDocumentService" PortName="FeatureRequestPort" SupportedOperations="Create, Delete, FindKeys, GetChangedKeys, Read, Update" RootDataSourceName="FeatureRequest_1" KeyInfo="RecId">
After:
<RootDefinition Name="AxdEntity_FeatureRequest_1" TypeName="AxdEntity_FeatureRequest_1" DisplayName="Feature Request Document Service" IsRequired="false" IsReadOnly="false" QueryName="AxdFeatureRequestDocument" ID="478ef2fe-b623-4f2f-8460-845df5720444" ServiceName="FeatureRequestDocumentService" PortName="FeatureRequestPort" SupportedOperations="Create, Delete, FindKeys, GetChangedKeys, Read, Update" RootDataSourceName="FeatureRequest_1" KeyInfo="RecId">
In order to get data to flow you must create new maps for your custom document service and custom entity.
The first step is to create a map that flows data from Microsoft Dynamics AX to Microsoft Dynamics CRM.
Destination
Mapping
CreateGuid(DAX Integration ID) *
Integration Key
* CreateGuid is a function in the mapping it will show as =CreateGuid(DAX Integration ID)
10. Change the map settings as followings
Setting
Value
Check for Changes
Every 30 Seconds
Check for Data Modified After
12/31/1899
11. Save the map
Now we must create the map in the other direction.
DAX Integration Id
Concatenate(“{“, Feature Request, “}”) *
* Concatenate is a function in the mapping it will show as =Concatenate(“{“, Feature Request, “}”)
Now that the maps are created we can activate them.
The final test is to enter some data. For Microsoft Dynamics AX we did not create a form to enter data, but we can do so quickly to make an easy way to enter a record. You can follow the MSDN article on “How to: Create a Simple List Form [AX 2012]” here: http://msdn.microsoft.com/EN-US/library/hh538488.aspx
For Microsoft Dynamics CRM we can customize the Microsoft Dynamics CRM form to add the fields we want to add. The data should now be able to flow in both directions.
I would like to personally thank our support engineers for developing this post as well as for assisting all of our customers! Stay tuned for an in-depth video series on this topic as well.