Showing posts with label error. Show all posts
Showing posts with label error. Show all posts

Tuesday, February 28, 2012

Issue with plug-in in CRM 2011

We had a requirement to do some calculation and update self record of custom entity. We have created a plug-in and registered it on post operation of update event. The code was reading the post image, updating some fields and updating the same.

The plug-in was working fine for single record. But when two records are saved simultaneously, the plug-in was giving below errors randomly.


1. "ValidateOpen - Encountered disposed CrmDbConnection when it should not be disposed"
2. "You cannot create a SqlExecutionContext from another SqlExecutionContext on which OnBeginRequest has not been called"
3. " System.InvalidOperationException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #58919D7E"
4. "System.NullReferenceException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #1638FFA8"

When we checked in the Event viewer then we got that whatever error we get from CRM the Event viewer shows "System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first." error.

After searching on net we found that CRM does not re-initialize the plug-in object again, it uses the same object. In the plug-in, ignore to use class level variables. We had created service object at class level so it was using the same service object for retrieving and updating.

Also we were reading post image and updating the post image as it is. This was also creating a problem. Please create a new object of Entity and then set only those fields which you want to update. Then update the record.

Sometimes this plug-in takes too much time as it was doing so many calculation. We were getting the "Query execution time of 30.1 seconds exceeded the threshold of 10 seconds. Thread: 4; Database: inogic_MSCRM " error when plug-in takes time. To resolve this, please add below keys in the registry on CRM server.
1) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\OLEDBTimeout
a. In seconds
b. The OLEDBTimeout value controls the SQL time-out value that is used for a single SQL query
c. Set it to 60 seconds


2) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\ExtendedTimeout
a. In milliseconds
b. The ExtendedTimeout value controls the ASP.NET time-out value
c. Set it to 1,000,000


3) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\NormalTimeout
a. In milliseconds
b. Specifies the SOAP call timeout for most operations
c. Set it to 300,000

Hope this helps!!

Tuesday, November 30, 2010

Workflows - Behind the scene

We were recently working on designing a tool that deletes workflow job. We thought it would be easy to just filter out all job that related to a workflow by the workflow id and then delete that’s it.

But like always we were in for a surprise. Just thought putting it down would help others in resolving this mystery.

Each Workflow has a unique id just like any other entity. But if you search for workflow jobs using this id to look for all jobs related to this workflow, you would be in for a surprise. It would not return all of the jobs that you are expecting. The reason being each time you revise a workflow i.e unpublish and publish the workflow once again, it creates a new workflow entry in the tables. If you want to look for the workflow jobs related to a particular workflow then you need to look for the workflow id assigned to each of its versions.

For workflow, you would find the following definitions available in the tables.


There will be only 1 definition record in CRM for a workflow no matter how many times you revise it.


But each time you publish a workflow it will create a new activation record.


The activation workflow record will have its parent workflowid set to the workflow definition id.

The workflow definition record will store the id of the currently active version of the workflow.

If you unpublish a worklfow and publish it again, it will add another row to the table and the status would now be as follows:


Note the activeworkflowid of the Definition record now refers the Guid of the latest version of the workflow that is published.

Now if you want to look for system jobs for this workflow, you will need to search for jobs that have their workflowactivationid set to any of the workflowid listed above in the table.

Hope this helps you find your way through the maze of workflows!!!

Thursday, August 6, 2009

Adding Money type attributes in Advanced Find causes error

If you were to add a money type of an attribute as one of the columns of a view you are designing, when you try to run the view, the results page will show an error message.


This is because the money type attributes require that the currency always be specified along with the money type attribute. To fix the above error all you need to do is include the currency attribute in the view and it will work just fine.



If you design a new custom Entity in CRM, the moment you add a money type of attribute, it automatically adds an attribute for currency called “transactioncurrencyid”.


If you forget to add the currency attribute on the form, when you try to provide a value in the money type attribute it will throw an error.


We have had various requests from customers who find the “Currency” attribute unnecessary as they work in a single currency and would like to avoid it. It is possible to remove the currency attribute from the form. But you can hide the currency attribute through scripting.

So in short… Money attributes require Currency attribute to tag along with them for them to function correctly.

Thursday, July 16, 2009

Sorting a CRM view by a Picklist Attribute causes an error

One of the best features of CRM is the ability to create your own views and be able to sort on any column of the view as and when you wish without having to redesign the view.

While this works great with all types of entities and attributes, we once came across with a bug when we tried to sort the view by the Status Reason Column. Status Reason column is a picklist type of attribute.

Upon further research we found that this fails for any Picklist attribute and only when one of the records present in the view has a null value set for the picklist attribute on which you are sorting the view.

To search for such null value records, you can look for the “Does not Equal” condition and select all the available picklist options.

You can just open this record and reset the value of the status reason and now the sorting on this attribute will work just fine.