Thursday, 28 May 2009

Change Field/Attribute requirement at runtime using javascript

Some times you come across with the situation when you have to make field mandatory on the form at runtime. Let say on selection of one field other field become required and if selection change field become business recommended or not required anymore.

On possible way is to use if-else statement to check if field.DataValue == null or not and respond accordingly. But following code can be used to make fields not required, required and business recommended.

  • crmForm.SetFieldReqLevel("fieldname",0); // set field to not required
  • crmForm.SetFieldReqLevel("fieldname",1); // set field to required/mandatory
  • crmForm.SetFieldReqLevel("fieldname",2); // set field to business recommended.

Hope this helps. Please drop some comments if script is helpful.

Note: The above code is not supported by Microsoft.

Tuesday, 5 May 2009

A time-out issue on importing customization file and/or on execution of Plugins

A very common issue when user import large customization file into MS Dynamics CRM 3.0 or into MS Dynamics CRM 4.0 the user get time-out error. Sometimes same issue occurs for smaller customization files if database is too large.

In some cases it has been noticed that if database it too large users gets similar error on the execution of normal operations especially like on execution of custom plugins and custom workflow activities.

User get errors like:
  • import timeout error.
  • Microsoft CRM Platform Error Report: Error Description: Timeout expired Error Details: Details on this error have not been provided by the platform. Error Number: 0x80040E31
Microsoft suggested few solutions to fix this issue among which is to add the OLEDBTimeout and ExtendedTimeout registry subkeys to increase the time-out values, which work incredibly well for me.

Refer:
http://support.microsoft.com/kb/918609

I have created .reg file and uploaded into Sky drive which adds these values into registry.

How to Add subkeys using .reg file:
Hope this helps. Please drop some comments if solution is helpful.

Note: If error is vague and does not make any clear sense then user can enable tracing. Please refer to my next blog which is regarding how to enable tracking in MS CRM Dynamics.

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.