CRM/NAV Connector – Crm Exception: Message: entity doesn’t contain attribute with Name = ‘name’

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

NAV

C:\Program Files (x86)\Microsoft Dynamics\Microsoft Dynamics Adapter\Adapters\Microsoft.Dynamics.Integration.Adapters.Nav2009\ObjectConfig

CRM

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

http://social.microsoft.com/Forums/en-US/crm/thread/6cf88569-3283-4902-b28b-f327ee1b27d6/

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)
                serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));

           if (context.PrimaryEntityName.Contains("<prefixforCustomEntities>")) //Replace with your prefix
            {

                tracingService.Trace("in the if statement");
                if (context.InputParameters.Contains(("Query")))
                {

                    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
=CreateGuid(“16A37447-9242-E111-8094-00155D6A3700”)
I’m not sure why it makes me do this whilst other entities allow you to use a lookup.

CRM/NAV Connector – How to map a custom table not included in the standard maps

If you use the connector regularly you will eventually want to map a custom table which isn’t covered by the standard maps.  To do this in CRM side is easy, you run the configuration utility and add the new entity but to do this in NAV requires a bit more work.

The connector works (as I understand it) by publishing tables/pages using a web service which is used by the connector to pass information from and to NAV.

The connector catches these web service calls in the code unit 5150 – intergration management.  If you were to open this up you would see the tables used by the standard maps mentioned.

So I am going to run through the process of adding Job to the custom maps.

First I open NAV and the correct database and company.  Then

Tools –> Object Designer  –> Codeunit –> 5150 –> Design

The first function you need to change is called

EnableConnector

You can see from the screen shot below I have also added in Site Address but that was just because I needed to do that, it’s not related to adding the Job table.

You need to copy one of the lines above,  paste it into the list and then change the details so you are referencing the Job table e.g.

If you are not sure what to add and you are adding something other than a Job then the first value is the Form Name and the second value is the table name, so if you were adding Job Planning lines then it would be

  SetupWebServicePages(FORM::”Job Planning Lines”,DATABASE::”Job Planning Line”);

 

 

The next function you have to change is called SetupIntegrationTables, you will need to add a new line for each table.

You might wonder why Job is not in double quotes.  Double quotes are needed if the table name has a space in it, otherwise you can just put the table name in.

The next function we need to change is IsIntegrationRecord, you add a reference to the table you want to add.  This function basically tells the connector you want the table to be added to the connector.

Be careful about adding  a comma if the row isn’t the last value

You have finished with the code changes, close the codeunit and press yes to save and make sure the compiled checkbox is ticked.

You now need to refresh the integration webservices so your new table is added and you do this by unchecking and checking the Enable Connector checkbox which is held in Marketing Setup.

You access the Marketing Setup by going to

Administration –> Application Setup –> Sales & Marketing –> Marketing Setup

 

Untick the box, check the tickbox.  After a bit of time you should see a new integration Web Service added to the list.

You can check this by going to

Administration –> IT Administration –> General Setup –> Web Services

You can see that the page is published and the new Integration Job Card Web Service is running.

Don’t panic if the Job Web Service doesn’t appear, first I would give it a bit of time.  I would try a good old close the NAV client down and open it again (this doesn’t really do anything but it will keep you busy for 30 seconds).

Finally if you don’t see the Web Service go back and check the code changes you have made, look for spelling mistakes, putting in the form name instead of the table name, missing comma.  The problem is going to be a syntax problem.

The final part of the puzzle is too run the NAV configuration utility in the Connector and tick the new Job Card entity

So

Open the Connector for Microsoft Dynamics

Adapter Settings –> Configure Microsoft Dynamics NAV –> Next –> fill in login details –> select Company –> tick Job Card

I think you might want to just enable the Job Card or the custom entity of your choice only on a specific integration.

hopefully the walk through above should help people add custom entities

CRM/NAV Connector not working after Connector upgrade to V2

I was trying to set up a new connector configuration whilst updating an existing connector installation.

One of the things I haven’t worked out is to have the connector connecting multiple NAV databases that use different services.

When you setup the connector you can only point it at one service in the adapter settings, unfortunately I would like to link to multiple services but this would mean having lots of different connector installations.

So instead I was replacing one and I thought I would upgrade the connector whilst I was there.

After upgrading the connector, I then couldn’t connect to the integration services.  The first reason was I didn’t have the correct license, DOH.  The second reason was the code units hadn’t compiled?!

I was getting the error below along with quite a few other error messages

I’m not sure why but when I was connecting to the connector integration web services I was getting compiled errors.

I initially recompiled the codeunits but this didn’t resolve the problem, so I then googled the problem and found some instructions which didn’t just compile the code units but ALL. I found these instructions on information about upgrading instructions for NAV 2009 R2, so it might have been a problem with the database I was using but I thought it was R2 (but my knowledge of NAV is not extensive)

Install and Upgrade Instructions for Microsoft Dynamics NAV 2009 R2

Performing a Solution Upgrade

You perform the following steps to upgrade a solution from Microsoft Dynamics NAV 2009 SP1 to Microsoft Dynamics NAV 2009 R2:

  1. Back up your Microsoft Dynamics NAV 2009 SP1 database.
  2. Uninstall Microsoft Dynamics NAV 2009 SP1.When you uninstall Microsoft Dynamics NAV 2009 SP1, your database is not removed.
  3. Install Microsoft Dynamics NAV 2009 R2 components. For more information, see Install and Configure Microsoft Dynamics NAV 2009 SP1 in the MSDN Library.If you use SQL Server with Microsoft Dynamics NAV, then you must select SQL Server Database Components, which were removed when you uninstalled Microsoft Dynamics NAV 2009 SP1, and select the Demo Database subcomponent of the Database components as Not available. If you do not exclude the Demo Database subcomponent, then you may see the following error message:Fatal error during installation. A database with name Demo Database NAV (6-0) already exists.

    The message may also advise you to delete the database. If you see this error message, then you can ignore it.

  4. Open the Classic client, and then connect to your database.A dialog box opens and says that the database must be converted before you can use it with this version of Microsoft Dynamics NAV Classic. ClickOK to convert your database.
    Gg502497.Important(en-us,NAV.60).gifImportant
    If you have installed the Classic client and the database on the same computer and you are running Microsoft Dynamics NAV 2009 R2 on Windows 7, Windows Server 2008, or Windows Vista, then click Start, point to All Programs, click Microsoft Dynamics NAV 2009, and then right-click Microsoft Dynamics NAV 2009 with Microsoft SQL Server. On the shortcut menu, click Run as administrator.
  5. Recompile all objects in your database. To recompile the objects, in the Classic client, on the Tools menu, click Object Designer. Click All, press CTRL+A to select all objects, and then press F11.

After I did that then I could connect to the connector integration services without any problems and I was on to the next step of adding a non standard map.

CRM/NAV Connector – Video – New features of V2 of the Connector

Here is an excellent video from msdyncomm which runs through the new features in V2 of the Connector for Microsoft Dynamics.

This is an indepth video which is 23 minutes long and goes through some of the features in detail like the new filtering functionality (which is excellent by the way)

CRM/NAV Connector – Heading in the right direction

I noticed a few links today from an article published on Dynamics world, you can read the article below

Microsoft Looking for Improved Sentiment on V2 of Connector for Dynamics ERP and CRM

The article is made up from quotes from a number of my blog posts on the connector and overall it gave the overall impression that using the CRM/NAV connector is hard work and can be difficult to use.

I was thinking about my comments and I would certainly say it hasn’t been easy and working with the connector has been very frustrating and I have had some wrestling to make it work.

On the other hand if you want to use the standard maps the connector works very well.  The problems arise when you want to do something that isn’t standard.

I am now onto my 3rd or 4th customer integration using the connector and I have done a few internally and it does start to get easier once you know the solutions to the problems that pop up.

I have also recently started to feel that Microsoft have made some movements in the right direction to make it a bit easier.

The biggest problem I experienced with using the connector was the complete lack of information on it.  There are hardly any blogs, videos or any type of information on it.  So as soon as anything goes wrong you are on your own trying to decipher the puzzling log messages.

On the plus side Microsoft have over the past couple of months released quite a few videos on the connector, which have been published on the dynamics connector blog

http://blogs.msdn.com/b/dynamicsconnector/

Microsoft have also released a new version of the connector which has fixed some of the problems which caused problems before.

The Dynamics Connector team know about the problems and been contacting users of the Dynamics connector to get feedback from them.

I would still say using the connector is more difficult than it should be.  I believe the Dynamics Connector team should have a weekly blog posting.  I assume there is a team of people working on the connector so for one of them each week to write a blog posting shouldn’t be too hard.  So what would I like to see

Examples of connector maps

more templates

walk-through (like adding an entity which isn’t in the standard maps)

common problems and solutions

Gotchas

I also hope that my blog posts on my experiences will help people in the present and the future who use the connector.

I think if the things below start to happen then the Dynamics connector could be pushed from difficult product to use to a good alternative solution to Scribe /writing a solution yourself.

1.   If the Microsoft Dynamics community can document their experiences and problems/solutions regarding the connector it would make a big difference, the more information out there the easy it will be to use and resolve any problems people experience

2.  The Microsoft Dynamics connector team can fix some of the more annoying issues like – More detailed logging messages, ability to transfer maps.

3.  Better documentation on how to use, setup and configure the dynamic connector

4.  More blog posts from the Dynamic Connector team.

5.  Decide on the title of the connector, is it the dynamic connector, CRM/NAV connector, Connector for Microsoft Dynamics??? just pick one and everyone can then use it.  This will make it a lot easier searching for solutions to problems.

CRM/NAV Connector – Video – Connector for Microsoft Dynamics Installation

A very useful video to help anyone who is trying to install the CRM/NAV connector

The connector installation has to be done in a certain order and if you turn the maps on in an incorrect order then you could receive hundreds or thousands of errors when maps try to run without the prerequisites maps having been setup and run first.