I have had two very frustrating days wrestling with the connector or to call it by its proper name the Connector for Microsoft Dynamics.
I was trying to map Jobs to Contracts, this worked fine, a bit of tinkering to work out what values I needed to put into Contract template lookups but this is to be expected.
I then wanted to map Job Planning Lines to Contract lines.
initially when I put in Job Planning Lines the form in NAV had a header record. This meant that I couldn’t generate a 1 to 1 mapping between Job Planning Lines and Contract lines because the header would be one record and the individual planning lines would be child records.
Eventually to get round this I put in the form as
Job Planning Line Subform
This is the child form on the Job Planning Line form, so it excluded the header.
I then ran the Connector config utility for NAV but because I had run it before it now doubled up and I had Integration Job Planning Lines and Integration Job Planning Lines Subform.
I also did something similar in CRM and ended up with duplicates for Contracts and Contract lines.
I’m not entirely sure why this happens but its very annoying.
In the end I had to delete the maps which are held in here and will be held with the name of the organisation/company you are mapping
C:\Program Files (x86)\Microsoft Dynamics\Microsoft Dynamics Adapter\Adapters\Microsoft.Dynamics.Integration.Adapters.Nav2009\ObjectConfig
C:\Program Files (x86)\Microsoft Dynamics\Microsoft Dynamics Adapter\Adapters\Microsoft.Dynamics.Integration.Adapters.Crm2011\ObjectConfig
I then ran the config utilities again and the duplicates were removed. I have no idea why this happens but it happens a lot and is quite annoying.
I then tried to map the Job planning lines and the contract lines now I had a one to one relationship.
I was getting this odd error
>Crm Exception: Message: ‘Contract’ entity doesn’t contain attribute with Name = ‘name’., ErrorCode: -2147217149
The reason I was getting this error is because I think the connector defaults it’s fetchXML to assume their is always a field called name. Contract unlikely for me changed this to be title.
This just didn’t work and I could find any information on the subject until I finally found this forum
Some excellent person found a solution, I also got some help from Konstantin Levchenko who has an excellent CRM/NAV Connector blog, have a look http://nav-connector.com/
to get this to work I had to create a plugin which intercepts the fetchXML by catching RequestMultiples and then change the FetchXml to not use Name but to use DynamicsIntegrationKey and then it works. This seems a crazy situation and why haven’t Microsoft written this as a plugin within instructions on how to do it.
public void Execute(IServiceProvider serviceProvider)
// Obtain the execution context from the service provider.
Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)
if (context.PrimaryEntityName.Contains("<prefixforCustomEntities>")) //Replace with your prefix
tracingService.Trace("in the if statement");
QueryExpression query = (QueryExpression)context.InputParameters["Query"]; ;
FilterExpression fexp = query.Criteria;
foreach (ConditionExpression condition in fexp.Conditions)
if (condition.AttributeName == "name")
condition.AttributeName = "dynamics_integrationkey";
I also had another odd thing was the owninguser field had to be filled in and I had to put in a guid.
I had to go and look up the guid for my user
I’m not sure why it makes me do this whilst other entities allow you to use a lookup.