SBX - Search With Button

SBX - Forum Post Title

Dynamics Connector - Product Name instead of Name Alias?

Microsoft Dynamics AX Forum

Simon Billeng asked a question on 3 Feb 2014 2:04 AM
My Badges

Question Status

Verified

Hello,

I'm working with the Connector for Microsoft Dynamics to integrate CRM 2011 and AX 2012. A problem I'm having with the Item service to Product map is the name field. Product Name in CRM should be mapped to Product Name in AX, but out of box it is mapped to Search Name.

The difference is that Search name is 20 characters long and Product Name is 30 (or atleast that is the structure of the data in our system), resulting in truncated names in CRM..

I can't find Product name anywhere in the source fields for the map.

Any suggestions?

Thanks in advance,

Simon

Reply
Parag Chapre responded on 14 Feb 2014 2:12 AM
My Badges

Hi Simon,

Hope you are doing Good.

Map below field.

Product Name (CRM) --- Name Alias (AX)

Once you map this you will get product name. Please let me know once you have done.

Reply
Simon Billeng responded on 14 Feb 2014 2:19 AM
My Badges

Hello,

That is the default mapping, and the problem with it is that in or AX 2012 (i dont know if it's by default) the Search name (or Name Alias if you will) is 20 characters long while the Product Name is 30 characters long.

The system will shorten the Product name (truncate) from 30 characters down to 20 , making the value not fit for the Product Name in CRM. Like "10 Meter Aluminium Foil Case" to "10mAluFoilCa" , something like that.

I don't understand why Product name from AX record is not present in the mappings. Can i expose it somehow?

Reply
Josephat Kutieto responded on 7 Aug 2014 4:20 AM
My Badges

Simon,

Did you get a solution to this?
I am experiencing the same problem...

An alternative would be to increase the Name Alias field in AX so as to accomodate all the characters in the corresponding Name field.

Thanks,

Josephat.

Reply
DM2014 responded on 15 Dec 2014 6:28 PM
Suggested Answer

Simon, 

The default Item Service pulls from InventTable. You need to go into the AOT, expand the queries section, find the InventTable and copy it. Rename it something suitable. Go to the datasources and add a table called EcoResProductTranslation. Set the relation fields to both equal "Product" (that's the field you are joining on). Save the query and now you can create a new document service to use that query. After creating the new document service via the wizard, reconfigure the AX Adapter so that you can see your new service.  Once you have your new service create a new map with CRM Product as the destination and copy all the mappings from the default Item Service to Product map to your new one- changing only the one from Name Alias to the Name field you are getting from the other table. 

The documentation is pretty good online for using the AIF Document Service Wizard if you haven't used it prior. If you get stuck, start the whole section again, sometimes it can be a little glitchy. 

Reply
Chris Roehrich responded on 17 Dec 2014 12:12 PM
My Badges
Verified Answer

One approach for this that I tested successfully is to create a custom function using the CRM Connector SDK guidance. The SDK is available at mbs.microsoft.com/.../mdax_dynamicsconnector.

The custom function calls a custom AX AIF service that is created from a query between InventTable and EcoResProductTranslation.  In the mapping window for the Product Name field, you will use the custom function to get beloved full product name!

High level steps:

1. Create a new AX AIF service based on a query that has InventTable as parent table and EcoResProductTranslation as child.  Join on Parent field.

2. After registering the service, create a new inbound Net.Tcp port in AX for this service.  Only need to add the read service operation.

3. Create custom function (C# library) using something like this:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Microsoft.Dynamics.Integration.Mapping; //assembly required for mapping functions in CRM Conn

using ItemNameFunction.IVName; //service reference

using System.ServiceModel.Channels; //Binding

using System.ServiceModel; //endpoint

namespace ItemNameFunction

{

   [MappingHelper]

   public class IVItemFunction : LocalizedMappingHelper

   {

       [MappingFunction(Description = "Returns the Product Full Name for the Product ID.")]

       [MappingFunctionCategory(Category = "AX Item to CRM Product")]

       public static string ReturnProdFullName(string ProdId, string Company, string URL, string Username, string Domain, string Password)

       {

           NetTcpBinding binding = new NetTcpBinding();

           binding.MaxReceivedMessageSize = 2147483647;

           binding.MaxBufferPoolSize = 2147483647;

           EndpointAddress remoteAddress = new EndpointAddress(new Uri(URL), EndpointIdentity.CreateSpnIdentity(string.Empty));

           InventTableCnServiceClient client = new InventTableCnServiceClient(binding, remoteAddress);

           client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential(Username, Password, Domain);

           CallContext cc = new CallContext();

           cc.Company = Company;

           QueryCriteria qc = new QueryCriteria();

           qc.CriteriaElement = new CriteriaElement[1];

           qc.CriteriaElement[0] = new CriteriaElement();

           qc.CriteriaElement[0].FieldName = "ItemId";

           qc.CriteriaElement[0].DataSourceName = "InventTable";

           qc.CriteriaElement[0].Value1 = ProdId;

           EntityKey[] keylist = client.findKeys(cc, qc);

           AxdInventTableCn item = client.read(cc, keylist);

           string accountName = item.InventTable[0].EcoResProductTranslation[0].Name;

           return accountName;

       }      

   }

}

4. Place the new dll file into C:\Program Files (x86)\Microsoft Dynamics\Microsoft Dynamics Adapter\MappingHelpers folder.  Close CRM Connector client, restart the Connector service, and open CRM Connector client.

5. In the Item Service to Product map, edit the Product Name field so it maps to the new function.  In this example, there are several parameters to map to.  Mine looks like:

=ReturnProdFullName(Item Id, "CEU", "net.tcp://DAX2012:8201/DynamicsAx/Services/InventTableCnServicePort", "administrator", "contoso", "pass@word1")

Reply
Tim Schofield responded on 17 Dec 2014 1:08 PM
My Badges

Search name is a field on the item master (InventTable).  But product name is related to the Product (the clue is in the fact that the field is not called Item name) and it's on another table.  I think it's something like EcoResProductTranslation - but I don't have the system in front of me to check  - and Product names are stored by Language

Reply
Chris Roehrich responded on 22 Dec 2014 8:32 AM
My Badges

The custom service in this example needs to be named InventTableCnService and have the following operations:

read

findkeys

Reply
Arun Garg responded on 14 Jun 2016 6:03 AM
My Badges

Hi .

It is mandatory while mapping fields from AX to CRM we need new map functions.

Regards

Arun

Reply
Chris Roehrich responded on 17 Dec 2014 12:12 PM
My Badges
Verified Answer

One approach for this that I tested successfully is to create a custom function using the CRM Connector SDK guidance. The SDK is available at mbs.microsoft.com/.../mdax_dynamicsconnector.

The custom function calls a custom AX AIF service that is created from a query between InventTable and EcoResProductTranslation.  In the mapping window for the Product Name field, you will use the custom function to get beloved full product name!

High level steps:

1. Create a new AX AIF service based on a query that has InventTable as parent table and EcoResProductTranslation as child.  Join on Parent field.

2. After registering the service, create a new inbound Net.Tcp port in AX for this service.  Only need to add the read service operation.

3. Create custom function (C# library) using something like this:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Microsoft.Dynamics.Integration.Mapping; //assembly required for mapping functions in CRM Conn

using ItemNameFunction.IVName; //service reference

using System.ServiceModel.Channels; //Binding

using System.ServiceModel; //endpoint

namespace ItemNameFunction

{

   [MappingHelper]

   public class IVItemFunction : LocalizedMappingHelper

   {

       [MappingFunction(Description = "Returns the Product Full Name for the Product ID.")]

       [MappingFunctionCategory(Category = "AX Item to CRM Product")]

       public static string ReturnProdFullName(string ProdId, string Company, string URL, string Username, string Domain, string Password)

       {

           NetTcpBinding binding = new NetTcpBinding();

           binding.MaxReceivedMessageSize = 2147483647;

           binding.MaxBufferPoolSize = 2147483647;

           EndpointAddress remoteAddress = new EndpointAddress(new Uri(URL), EndpointIdentity.CreateSpnIdentity(string.Empty));

           InventTableCnServiceClient client = new InventTableCnServiceClient(binding, remoteAddress);

           client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential(Username, Password, Domain);

           CallContext cc = new CallContext();

           cc.Company = Company;

           QueryCriteria qc = new QueryCriteria();

           qc.CriteriaElement = new CriteriaElement[1];

           qc.CriteriaElement[0] = new CriteriaElement();

           qc.CriteriaElement[0].FieldName = "ItemId";

           qc.CriteriaElement[0].DataSourceName = "InventTable";

           qc.CriteriaElement[0].Value1 = ProdId;

           EntityKey[] keylist = client.findKeys(cc, qc);

           AxdInventTableCn item = client.read(cc, keylist);

           string accountName = item.InventTable[0].EcoResProductTranslation[0].Name;

           return accountName;

       }      

   }

}

4. Place the new dll file into C:\Program Files (x86)\Microsoft Dynamics\Microsoft Dynamics Adapter\MappingHelpers folder.  Close CRM Connector client, restart the Connector service, and open CRM Connector client.

5. In the Item Service to Product map, edit the Product Name field so it maps to the new function.  In this example, there are several parameters to map to.  Mine looks like:

=ReturnProdFullName(Item Id, "CEU", "net.tcp://DAX2012:8201/DynamicsAx/Services/InventTableCnServicePort", "administrator", "contoso", "pass@word1")

Reply
DM2014 responded on 15 Dec 2014 6:28 PM
Suggested Answer

Simon, 

The default Item Service pulls from InventTable. You need to go into the AOT, expand the queries section, find the InventTable and copy it. Rename it something suitable. Go to the datasources and add a table called EcoResProductTranslation. Set the relation fields to both equal "Product" (that's the field you are joining on). Save the query and now you can create a new document service to use that query. After creating the new document service via the wizard, reconfigure the AX Adapter so that you can see your new service.  Once you have your new service create a new map with CRM Product as the destination and copy all the mappings from the default Item Service to Product map to your new one- changing only the one from Name Alias to the Name field you are getting from the other table. 

The documentation is pretty good online for using the AIF Document Service Wizard if you haven't used it prior. If you get stuck, start the whole section again, sometimes it can be a little glitchy. 

Reply

SBX - Two Col Forum

SBX - Migrated JS