Unwanted headache due to data type mismatch

First of all let me explain how my MS CRM Dynamics 4.0 system gets it's data.

Like any other company we have one big ERP/PMS that is our main data source and other small ERP/PMS systems. Most of this systems rely on MS SQL Server technology (2000 and 2005) for their database needs. This is great because it allows us to use SQL Server 2005 Integration Services (SSIS) to pump the data from each system's database and consolidate it to a single database. In the BI (Business Intelligence) world this process is called ETL or Extraction, Transformation and Loading. Although here we rely on the SSIS for the Extraction and Transformation phases and then we use CrmService webservice to send data to the CRM (create, update). Doing this we make sure our CRM and our ERP/PMS systems are automatically synched. Although this sounds very simple and you can learn it by yourself it really speeds up the process if you can get help from someone more experienced.

We are now developing the console application that will run in the background. This app will be responsible for retrieving data from the ETL databse and push it to the CRM using the CrmService webservice. For instance, we retrieve one contact (transformed) from our ETL database and then we push it to the CRM but first we need to know if the contact already exists there. Why's that? If the contact exists we use the Update method, if it doesn't we use the Create method. How to determine if he exists? Simple, choose a key field such as ERP/PMS customer number. This ERP/PMS primary key (PK) will act as a foreign key (FK) for our contact. If the contact is found we return the GUID and then call the Update method.

For more details about CrmService and it's methods I would advise you to take a look at Working with Microsoft Dynamics CRM 4.0 and Microsoft Dynamics CRM 4.0 Unleashed. This books are good starting points for learning how to use the CrmService. They are better used together as one has more details but fewer examples and the other has more examples and fewer details.

After some initial coding and successfull testing (retrieve data, push data) using the new much appreciated Visual Studio 2008 our problems began. Our last build of the console application crashed again and again and we didn't know why. Through debbuging we realized that it was a problem related with our RetrieveMultiple method call. After a couple of ours of nonsense coding we caught the bug: earlier we had changed an entity attribute from picklist to string (delete attribute, new attribute, save and publish), however our webreference (Visual Studio 2008) didn't reflect that change and we had to remove the web reference and add it again in order to "squish" the bug! This picture saved the day!

No comments:

Post a Comment