Thursday, September 4, 2008

Dynamics CRM and Great Plains integration

**
Update Oct '08 
thanks to Jivtesh who pointed out that this has been resolved in the GP 10 installer 
**


I've been trying to provide some basic integration between CRM and GP for a demonstration, and since we have a VPC with Windows Server 2003, Windows AD, MS SQL Server 2005, IIS and CRM 4.0 already installed, it made sense to quickly install GP on the VPC; slap on the Web Services and away we go!

The plan was to create a custom aspx page that loads the Sales Order History for a debtor, and display it on a data grid; then to load that page from within an iFrame, passing the GP debtor ID as a parameter within the URL. We can store the GP debtor ID in the 'Account Number' field on the CRM Account entity.

So, first attempt: I couldn't load GP from the installer, because .NET 2.0 was not installed. Hmm. Yes it was, in fact I had .NET SP1 and .NET 3.0 SP1 installed. But the GP installer didn't recognise .Net 2.0 SP1 as a valid install of .Net 2.0. So I hunted and saw KB947538, available on PartnerSource, giving instructions on how to crack the msi, skipping the .Net check.
Seems simple enough.

Except it just didn't work. I was told that 'Microsoft Application Error Reporting' was not installed (which actually has something to do with Dr Watson), except it was... So I spent quite a bit of time trying to get Dr Watson installed, and get through to the installer. A bit of jiggery pokery later, I had the core GP product installed, and optimistically moved onto the Web Services installation...

I wasted an hour or so by getting myself confused between the Domain for the VPC AD (LITWAREINC) and the machine name (MOSS - Incidentally, why is the CRM VPC called MOSS?) - but that was my mistake, and when I put the right credentials in, I installed the Web Services straight away. Browse to them... there they are. Hurray!

So now for the application code. Firstly, go to the SDK documentation; and it really is very good. There's sample code for each and every web method, and I quickly put together a function to connect to GP, and get all Sales Orders for a debtor, filtered by debtorId.
But it didn't work.
I connected to the Web Service, but when I invoked the relevant method (GetSalesOrderList) it simply threw an unhandled exception. Bah :(

I wish I could tell you exactly what the problem was; I wish I knew more about the minutiae of Microsoft technologies; I wish I had a gold-plated Cadillac...

So anyway, I took a vanilla CRM VPC, and followed the advice of the many developers on the forums who told me (about 3 days ago!!) to simply uninstall .net before the GP install, then re-install it after...


Basically:
- uninstall .Net 3.0 SP1   (you have to uninstall the later framework, otherwise the .net 2 uninstall fails)
- uninstall .Net 2.0 SP1
- Install GP, which will install .Net 2.0
- Install GP Web Services
- Reinstall .Net 3.0
- Reconfigure IIS to set the Dynamics CRM web folder to use Asp.net v2.0.50727; since the uninstall of .Net 2.0 reverted the site to use v1.1.4322, which breaks CRM.
- Let Windows update patch the 2 frameworks up to SP1...

Bob's your uncle; the methods seem to work now, and we can (finally) start on the aspx page.

Hope this helps anybody attempting to 'quickly' put a demo together of these two integrated technologies.