Sunday, 3 May 2009

Error when trying to create a new crm 4.0 custom entity

Few days ago I was experiencing a problem in creating new entity in MS CRM 4.0. The problem initally started when organization is imported into new installation. I was getting following error message. I have three environments: Dev, Test and Live and was experiencing same issue in all three environments.

Error Message:
An error has occured.Please contact your system administrator or go for online help. (In short)

Trace Log Detail:
Error: ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.
Error Message: ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.
Source File: Not available
Line Number: Not available
Request URL:
http://irfansaeed.net/XXXX/AppWebServices/SystemCustomization.asmx
Stack Trace Info: [InvalidOperationException: ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.] at System.Data.SqlClient.SqlConnection.GetOpenConnection(String method) at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command) at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command) at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate) at Microsoft.Crm.CrmDbConnection.SetTransactionIsolationLevel(IsolationLevel il) at Microsoft.Crm.CrmTransaction.RollbackTransaction(Boolean raiseException) at Microsoft.Crm.SqlExecutionContext.RollbackTransaction() at Microsoft.Crm.Metadata.EntityService.Create(EntityCreateInfo entityInfo, ExecutionContext context) at Microsoft.Crm.Metadata.EntityService.Create(EntityCreateInfo entityInfo) at Microsoft.Crm.Application.WebServices.SystemCustomization.EntityCreate.Execute(IUser user, ParameterBag paramBag) at Microsoft.Crm.Application.WebServices.SystemCustomization.SystemCustomization.CreateEntity(XmlNode data)

Solution:
After putting lot of investigation I managed to fix this issue.

  • Export "System Customizer" role from out of the box new MS CRM 4.0 installation,
  • Import "System Customizer" role into the deployment which is having this issue.
  • Remove existing System Customizer role from the users who are assinged with this role and add back again. (this step can be performed before first step).

Note: In some cases users are experiencing issues with time out and this can be fixed by adding OLEDBTimeout and ExtendedTimeout into the registy. (Please refer to my next blog which is regarding how to increase timeout and set values in registry.)

Please post comments if solution helpful.

3 comments:

Mark said...

Thanks.. Nice post..
fix work like a charm... :)

Anonymous said...

helpful..

I was experiencing similar issue, can't remember what was the trace of the error, but I got it fixed by restarting SQLServer and IIS. Idea bhind is if SQLServer is taking lot of resource and database is too big then restaring SQl make it bit lighter..
Hope it helps..

Pranav Shah said...

Well, I wasn't sure how to export and import "System Customizer" role so I tried the following and it worked for me

In the begining, I had OLEDBTimeout set to 86400 and it worked for few days and back to same error again

Later, I shrinked temdb database, restart both SQL and CRM server and worked couple of times during entity creation and back to the same error again

And now I renamed "System Customizer" role, copy "System Administrator" role to "System Customizer" and it worked, for couple of entity creation attempts in few mins. However I am not sure if this solution will be long lasting though. Will keep posted if any progress.

-Pranav Shah

Post a Comment