Monday, September 23, 2013

MS Dynamics CRM 4.0 - Synchronize Dev, Testing and Production Servers

As an MS CRM developer, you would like to maintain the Production and Testing Servers in sync which helps to bring good quality of deliverable by maintaining a good testing environment. I have faced a couple of times that our projects works well in the testing environment and we get a go ahead to push into the production where it creates some sort of issues. Either we have to fix them right away or revert the new changes to reduce the inconvenience caused to the end users. It would be a real challenge to debug the issue on the Production environment which doesn't produce any error in the Testing/Dev environment.

By maintaining a sync between production and testing environments these kinds of issues can be reduced to a greater extent. We have had a testing environment that is completely out of sync and not having the customization's developed in the last couple of months. I decided to pull the testing server in sync with the production server in order to make my life much easier in further development. Therefore, I tried to find different ways to accomplish this in an easier way and finally came up with the solution of Import Organization feature from Deployment Manager.

This is clearly explained in the below article from Joel.

Happy synching!

Tuesday, April 24, 2012

SQL Server - Read Excel, CSV 2003, 2007 files using OpenRowSet

In SQL Server, we can read the data directly from an Excel file or a .csv file using OpenRowSet function as given below:

For OPENROWSET function to work properly in SQL Server 2005, you need to check "Enable OPENROWSET and OPENDATASOURCE Support" using SQL Server Surface Area Configuration for Features.

 Once you are done with that you can make use of the below queries to read the data:

--Read .CSV file from a 32 bit SQL Server 
SELECT * FROM OPENROWSET
('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DEFAULTDIR=D:\DWP Deliverables\CSPRojectIntegration\;Extensions=CSV;','SELECT * FROM CSProjects.csv')


--Read Excel file from a 32 bit SQL Server 
SELECT *  FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=D:\DWP Deliverables\CSProjects.xls',
'SELECT * FROM [Sheet1$]')


--Read Excel 2007 file from a 32 bit SQL Server 
Another workaround is trying to install Microsoft.Jet.OLEDB.12.0, and use your connection string with OLEDB 12.0, it can be downloaded at :
2007 Office System Driver:  http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=7554f536-8c28-4598-9b72-ef94e038c891

On the other hand, you can save the 2007 file to 2003 format and try reding it from OLEDB4.0 driver

--Read files from 64 bit SQL Server
JET OLEDB Provider works only with 32 bit. For 64-bit OLEDB Provider for ODBC you have to install MSDASQL using the below link http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=20065#overview


Hope this helps!!

Monday, April 23, 2012

MS CRM SQL Server CPU Utilization shows 100% - Troubleshooting steps


We had a weird issue with MS CRM SQL server recently where the CPU utilization of sql server constantly shows 100% for a long time. When we checked in the task manager we found that sql process alone is taking around 98 - 99%. We have application and database on different servers. We tried to reboot both the servers couple of time and the behavior is such a way that the utilization goes down whenever we restart the machine and raises up to 100% after 10-15 min.

But the only relief from our side is the CRM application is not entirely down but the performance was less.So, we got some time to debug into the issue.

We tried the following steps in our process of troubleshooting the issue:

  1. First thing to check if there are any recent changes or deployments made to the system.
  2. In the task manager check the process that is consuming the cpu utilization.
  3. Check the application logs and system logs in EventViewer of the crm server. If the app server and sql servers are hosted in different servers then check the event logs in both the servers.
  4. Stop the Asynchronous Service in MS CRM server and check the cpu utilization. If it gets down then issue is probably with the ms crm app server. It could be due to customizations you made which is running into deadlock situations.
  5. If it is still showing 100% then stop the sql server services and check the utilization.
  6. Start the CRM AsyncService and see the utilization.If it works fine, then start the sql services as well.
  7. If you still find the issue, you can Start Running the SQL Profiler to see if any query is taking long time to execute. If you find any, then disable the functionality that is making use of that query for a while and check the utilization.
  8. Check if any event log appears in System. Check if automatic windows updates are turned ON on the server. Sometimes windows updates might not run successfully and causes the issue so check the last updated time from windows and see if the error in the event log starts occurring from that time. It will  be set when the windows updates run for the next time or you can manually run the windows updates and restart the server.
 The reason in my case is the automatic window updates failed to run successfully that impacted the sql server process.

If the above steps did not resolve your issue and if you are making use of some third party services running on the same server then, instead of restarting the services, try stopping the services one at a time, check if there is any impact on the utilization and once you are done with stopping all the services and start the services one at a time. This way you can get closer to the root cause of the issue. 

Hope this saves sometime in your debugging process!!

Wednesday, April 4, 2012

MS CRM 4.0 How to view detailed Error Message

It is a common practice for the developers working on MS CRM to view the exact error message to fix the issues instead of seeing the custom error page displayed to the end user.
In order to view the error message, below are the different options available
  1. Enable Trace which logs the details of the error. This can be implemented on live server so that end users still see the custom error message instead of the original error
  2. Modify the web.config file to set "DevErrors" to "On" on the MS CRM server as per the below microsoft article http://support.microsoft.com/kb/857192

Sunday, March 25, 2012

How to create a dropdown or picklist column with a list of values in ms excel

Say we would like to create a drop down column in excel sheet with a list of predefined values. Create a list of predefined values in a new sheet and select the list of values and right click and select Name a Range..and give some name say "MyCustomList"

Now click on the column on which you would like to create a dropdown. 
Select Data on the top menu and go to Data Validation -> Data Validation. In the validation criteria, select list in the allow section and give the Source as the name of the range you have chosen like
 =MyCustomList

Click ok to see the dropdown column with the list of values defined in the range. If you want to remove the dropdown then under Data validation, choose Allow Any value.



MS CRM 4.0 Enrich Data - Update MS CRM Records using Excel

By using native data import feature in MS CRM 4.0, we have the ability to update the existing data apart from creating new records. This is called Data Enrichment which is the new feature brought up in MSCRM 4.0. This can be done by exporting your data into an Excel Sheet. In general, when we export the data to a static excel sheet, you find the excel sheet columns start from B instead of A. This column A is in hidden state which holds the GUID of existing record.
If you are so curious, you can unhide the column A to see the GUID. Please follow the steps in this link to unhide the excel columns.

Make your changes to the data in the same excel sheet and save it as a .CSV file. Now, re-import the data using standard data import wizard. This time when you upload the file, you will be pointed to a new checkbox option 'Enrich data by updating existing records rather than creating new records'. This option is used to update the changes you made for the existing records instead of creating new ones.

MS Excel How to view hidden columns

You can unhide any column in MS Excel by using the following steps.
1. Select all the columns using Ctrl+A
2. Point the cursor on any column and right click and Unhide. That's it. Now you can see all the hidden columns in the excel sheet.

Saturday, March 24, 2012

Scribe Integration with MS CRM Mapping Picklist field in DTS

1. Open up your DTS file and select your source and target fields and click Datalink
2. Now, Right click on the target field and Edit Data Formula.. Click on calculated variable and put the source field like S1 and point the dropdown to String
3 Next, insert this calculated variable in the formula and voila!
4. This maps your source picklist field with text values to the target picklist fields

Scribe Integration with MS CRM Map Lookup field in DTS

1. Open DTS file and select your source field and targte lookup field and click DataLink
2. Right click on the target lookup field and click on Edit Data Formula..
3. Use DBLookup function as

Syntax: DBLOOKUP( TextSourceField, "connection", "table", "lookup_field", "substitution_field" )
Where connection = "T" for Scribe versions below 7.0 and connection = "Adapter for Dynamics CRM" for Scribe 7.0 and later.
Example for an Account lookup field
DBLOOKUP( S1, "Adapter for Dynamics CRM", "account", "name", "accountid" )

Sunday, March 11, 2012

MS CRM Workflows Waiting and Failed - How to check the error details

1. Open Advanced Find and point the entity to System Jobs
2. Add the filter criteria as defined below:
   SystemJobName Equals your_customworkflow_name
   ErrorCode ContainsData
3. Edit the columns and include MessageName, ErrorCode
4. Click Find to get the list of records that got failed in running the custom workflow with a
   detailed error message