CRM 2011 – NAV Connector Gotcha’s

I had to use the CRM/NAV connector this week.  I have to admit I have a heavy heart when ever I have to use the CRM/NAV Connector, it is never easy and amazingly frustrating.

The main problem I have with the connector is the complete lack of examples and documentation and when you start using it, it feels like the connector is a black hole.

Things go in and out but you are never really sure what is happening in the middle and usually why things are not working.

I had to Synchronise the Account entity and two custom entities.  The connectors tool for making custom entities available inside the connector mapping tool is very good.

When you get to the NAV side you have to change the integration table and the best instructions I have found on this is this fantastic blog post which steps through what you have to do.

I had one odd problem, even though I chose not to map contacts and removed all mention of contacts on mapping, if a contact was selected on the account primary contact, it would not sync the account.

even though I didn’t want to sync the contact, it still wouldn’t sync.

After mucking around for a few hours I found that you have to set the dynamics integration field on the contact, if you do this when the account will sync.

another NAV connector gotcha is if you are mapping new entities and non standard tables in NAV then you need to make sure you set the Intergration ID value

I had an entity called Project and on the mapping from CRM to NAV you have to set the Integration ID with the Project\ID

if you don’t set this it will map the change for the first time but then any changes will fail because it can’t link to the entity in CRM without the Integration ID being set

CRM 2011 – The easy way not to select all columns in queries

I had got into the bad habit of returning all columns when I was doing a query, well I would certainly do that when I was developing and then change it later.

I wanted a way to select only the columns I wanted but without creating lots of functions selecting different columns.

The solution I came up with was to pass a list into the function and the list held the columns I wanted to select.

So now I pass in a list of field names held in a list and it returns me those columns, this means I can use the same code and I am also not whacking the database by returning lots of columns I don’t need.

Below is the code I use to select Accounts

public Account getAccountDetails(IOrganizationService service, Guid guid, List<string> fields)

ConditionExpression condition1 = new ConditionExpression();
condition1.AttributeName = “accountid”;
condition1.Operator = ConditionOperator.Equal;

FilterExpression filter1 = new FilterExpression();

QueryExpression query = new QueryExpression(Account.EntityLogicalName);

ColumnSet cols = new ColumnSet();
query.ColumnSet = cols;


EntityCollection result1 = service.RetrieveMultiple(query);

IEnumerable<Account> accounts = result1.Entities.Cast<Account>();
Account account = (Account)returnOne(accounts);

return account;


This is the code I use to call it

List<string> fields = new List<string>(){
Account account = pluginQuery.getAccountDetails(service, accountGuid,fields);


The comment below from Georg Müller (@ggmueller) improves the code to make it much easier to use, so thanks for that.  I liked the comment so much I have bumped it into the main blog post.

If you change the from List to String[] then it can save you making a list

Account getAccountDetails(IOrganizationService service, Guid guid, params string[] fields)

as interface. This way you can use it as
Account account = pluginQuery.getAccountDetails(service, accountGuid, “name”, “emailaddress1″) for example.

Over 200000 views and still on the up

I passed the 200000 views 2 weeks ago but I got distracted blogging about other more interesting things like CRM 2011.

I’m currently at 214000 views.

The blog has been going in full force for about 1 year now (I did start it in 2009 but only did it for a month)

The growth of the blog this year has been amazing, there has been a lot to blog about with the release of CRM 2011.  I hope my blog has helped people using CRM 2011 and thanks to everyone who has or still does read my blog

here are some of the stats below, one amazing stat is I have written 457 blog posts, most of them in the last year, that is a lot of blog posts.

The stats are probably missing quite a lot of people because wordpress doesn’t count people who read the blog using an RSS feed.  I also have my blog shown on Microsoft’s community blog place, where people can read the blog without actually visiting my blog because Microsoft insist you publish the whole blog post

Months and Years

Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Total
2009 148 37 2 12 4 3 1 4 4 0 3 218
2010 2 4 0 2 0 4 1 1 1 0 1 240 256
2011 988 3,285 8,703 16,297 24,237 24,212 23,047 26,054 22,833 26,088 27,481 11,071 214,296

Average per Day

Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Overall
2009 5 1 0 0 0 0 0 0 0 0 0 1
2010 0 0 0 0 0 0 0 0 0 0 0 8 1
2011 32 117 281 543 782 807 743 840 761 842 916 922 619