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.
本文适合想尝试用Connector同步AX的自定义数据字典和CRM中的自定义实体的用户进行阅读. 如果你打算同步一个CRM的自定义实体到AX 2012中,但是AX却没有与之对应的预制数据字典或者你想让一个在存在于AX中的自定义表格获取保存在CRM中的某个实体的信息,那么这边博文将会给你提供有用的建议. 在实验前我们首先需要在AX2012和CRM中分别建立用来演示的Feature request自定义数据字典或自定义实体.
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.
本文会指出如何在AX 2012中创建自定义数据字典,如何在CRM 2011种创建自定义实体,如何把保存在这些自定义容器中的数据暴露给Connector,以及如何设置Connector的数据同步规则。 本文不讨论删除数据的同步, 因为它还不被现在版本的Connector支持。
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:
要实体AX与CRM的同步第一步取决于你想同步什么样的数据,大家可以按如下信息分别在AX和CRM中创建自定义数据字典和自定义实体
Component |
Name |
Property |
Property Value |
Table |
FeatureRequest |
|
|
|
|
CreateRecIdIndex |
Yes |
|
|
PrimaryIndex |
PrimaryIndex |
|
|
ClusterIndex |
PrimaryIndex |
|
|
ModifiedDateTime |
Yes |
|
|
ModifiedBy |
Yes |
|
|
ModifiedTransactionId |
Yes |
|
|
CreatedDateTime |
Yes |
|
|
CreatedBy |
Yes |
|
|
CreatedTransactionId |
Yes |
|
|
|
|
Fields (FeatureRequest) |
FeatureId |
|
|
|
|
Type |
String |
|
|
Name |
FeatureId |
|
|
Label |
Feature ID |
|
|
Help Text |
The ID of the Feature |
|
|
Mandatory |
Yes |
|
|
StringSize |
20 |
|
|
|
|
|
FeatureName |
|
|
|
|
Type |
String |
|
|
Name |
FeatureName |
|
|
Label |
Feature Name |
|
|
Help Text |
The Name of the Feature Being Requested |
|
|
StringSize |
50 |
|
|
|
|
|
RequestedDate |
|
|
|
|
Type |
Date |
|
|
Name |
RequestedDate |
|
|
Label |
Requested Date |
|
|
Help Text |
The Date The Feature Request Was Made |
|
|
Mandatory |
No |
|
|
|
|
|
|
|
|
|
FeatureDescription |
|
|
|
|
Type |
String |
|
|
Name |
Feature Description |
|
|
Help Text |
The Description of the Feature Being Requested |
|
|
Mandatory |
No |
|
|
StringSize |
1000 |
|
|
|
|
|
DAXIntegrationId |
|
|
|
|
Type |
GUID |
|
|
Name |
DAXIntegrationId |
|
|
Label |
Dynamics AX Integration ID |
|
|
Help Text |
The ID Used for the Dynamics Connector AX Adapter |
|
|
Mandatory |
No |
|
|
|
|
Index (FeatureRequest) |
PrimaryIndex |
|
|
|
|
Name |
PrimaryIndex |
|
|
AllowDuplicates |
No |
|
|
Enabled |
Yes |
|
|
AlternateKey |
Yes |
|
|
Fields |
FeatureId |
|
|
|
|
Methods (FeatureRequest) |
insert |
|
|
|
|
Name |
insert |
Event Handler Subscription (insert of FeatureRequest) |
|
|
|
|
|
Name |
DynConn_InsertHandler |
|
|
CalledWhen |
Pre |
|
|
EventHandlerType |
X++ |
|
|
Class |
DynamicsConnector |
|
|
Method |
SetDAXIntegrationId |
|
|
AOTlink |
\Classes\DynamicsConnector\ SetDAXIntegrationId |
|
|
|
|
Query |
FeatureRequestQuery |
|
|
|
|
Name |
FeatureRequestQuery |
|
|
Title |
Feature Request Query |
|
|
Description |
Query For Feature Request Table |
Data Sources (FeatureRequestQuery) |
|
|
|
|
FeatureRequest_1 |
|
|
|
|
Name |
FeatureRequest_1 |
|
|
Table |
FeatureRequest |
|
|
Update |
Yes |
|
|
|
|
Fields (FeatureRequest_1) |
|
|
|
|
DAXIntegrationId |
|
|
|
|
Table |
FeatureRequest |
|
FeatureDescription |
|
|
|
|
Table |
FeatureRequest |
|
FeatureId |
|
|
|
|
Table |
FeatureRequest |
|
FeatureName |
|
|
|
|
Table |
FeatureRequest |
|
RequestedDate |
|
|
|
|
Table |
FeatureRequest |
|
RecId |
|
|
|
|
Table |
FeatureRequest |
Execute the AIF Document Service Wizard to create a new Document Service.
执行AIF Document Service 创建向导创建一个新的服务。
Query |
FeatureRequestQuery |
Document Identification |
|
Document Name |
FeatureRequestDocument |
Document Label |
FeatureRequest |
Class Names |
|
Service Class Name |
FeatureRequestDocumentService |
Document Object Class Name |
FeatureRequestDocument |
Axd Class Name |
AxdFeatureRequestDocument |
Service Operations |
|
Create |
True |
Read |
True |
Update |
True |
Delete |
True |
Find |
True |
FindKeys |
True |
GetKeys |
True |
GetChangedKeys |
True |
AxBC Generation |
|
Generate AxBC Classes |
True |
|
|
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.
为了使AIF Document Service能顺利发布你可能需要实现CacheObject,CacheRecord方法或将它从AxFeatureRequest类中进行删除。
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
创建完AIF Document Service后,接着就需要配置服务的Inbound Port。我们可以在这里配置它:System Administration--Service and Application Integration Framework--Inbound ports area。
Property |
PropertyValue |
|
|
Port Name |
|
|
|
|
FeatureRequestPort |
|
|
Service Operations |
|
|
|
|
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
现在我们已经完成了AX的配置了,现在我们来配置CRM,具体配置信息如下:
Component |
Name |
Property |
Property Value |
Solution |
Feature Request Solution |
|
|
|
|
Display name |
Feature Request Solution |
|
|
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 |
Feature Request |
|
|
Plural Name |
Feature Requests |
|
|
Name |
frsp_featurerequest |
|
|
Ownership |
User or Team |
|
|
Notes |
Yes |
|
|
Activities |
Yes |
|
|
Connections |
Yes |
|
|
Duplicate Detection |
Yes |
|
|
Primary Field Display Name |
Name |
|
|
Primary Field Name |
frsp_name |
|
|
Maximum Length |
50 |
|
|
|
|
Field (Feature Request) |
Requested Date |
|
|
|
|
Display Name |
Requested Date |
|
|
Name |
frsp_requesteddate |
|
|
Type |
Date and Time |
|
|
Format |
Date Only |
|
|
|
|
|
Feature Id |
|
|
|
|
Display Name |
Feature ID |
|
|
Name |
frsp_featureid |
|
|
Type |
String |
|
|
Maximum Length |
20 |
|
|
Requirement Level |
Business Required |
|
|
|
|
|
Feature Description |
|
|
|
|
Display Name |
Feature Description |
|
|
Name |
frsp_featuredescription |
|
|
Type |
Multiple Lines of Text |
|
|
Maximum Length |
1000 |
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.
现在我们来配置Connector的Dynamics CRM 2011 adapter吧:
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.
现在我们来配置Connector的Dynamics AX 2012 adapter吧:
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">
注意:完成了如上步骤后我们还需要修改AX 2012 adapter生成的配置文件(因为现在版本的connector还不够完善),按照如下路径找到adapter的配置文件“This file can be located in %ProgramFiles(x86)%\Microsoft Dynamics\Microsoft Dynamics Adapter\Adapters\Microsoft.Dynamics.Integration.Adapters.Ax2012\ObjectConfig\<AOSServerName_DocumentPort>\” 将QueryName修改为AX AIF Service的类名,类名可以在AX中查看。
In order to get data to flow you must create new maps for your custom document service and custom entity.
为了让AX和CRM的数据真正同步起来,我们需要创建一个同步规则
The first step is to create a map that flows data from Microsoft Dynamics AX to Microsoft Dynamics CRM.
创建AX到CRM方向的同步规则
Destination |
Mapping |
Feature ID |
Feature Id |
Name |
Feature Name |
Feature Description |
Feature Description |
Feature Request |
CreateGuid(DAX Integration ID) * |
Integration Key |
Feature Id |
Requested Date |
Requested Date |
* 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.
CRM到AX方向的数据同步配置类似于AX到CRM方向。
Destination |
Mapping |
DAX Integration Id |
Concatenate(“{“, Feature Request, “}”) * |
Feature Description |
Feature Description |
Feature Id |
Feature ID |
Feature Name |
Name |
Requested Date |
Requested Date |
* Concatenate is a function in the mapping it will show as =Concatenate(“{“, Feature Request, “}”)
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 that the maps are created we can activate them.
在AX和CRM中分别创建数据,查看Connector是否配置成功。
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.
From:
http://blogs.msdn.com/b/dynamicsconnector/archive/2013/05/10/customizing-a-microsoft-dynamics-ax-2012-and-microsoft-dynamics-crm-2011-integration.aspx