I have a custom workflow in CRM 2011 which is manually triggered against custom entity records. When a single record is selected for processing, the workflow is always successful. However when selecting more than one record, at least one will fail. The error(s) provided seem to vary from one attempt to the next, even though the same data is being used.
Errors I've encountered so far are:
And after restarting the DB server:
All of these occur when calling the Update method of the IOrganizationService. The Invalid Pointer error seems to be the more common error since having restarted the DB server (it was suggested to me that it might be an issue with an overly-busy DB server). I've also deleted any backlog of asynchronous tasks in case this was the issue, but it hasn't had any effect.
Does anyone know what this error means, why I might be getting it or how I can get around the issue?
Many thanks!
It seems this error message is a round-about way of saying, 'tried to open another connection to CRM when the previous one was open', and the reason it tries to do this is very much relevant to the fact it only fails when processing more than one record.
Reference this blog:
It seems that when a workflow is run against multiple records, it uses the same instance of the class, which means that class-level variables won't be re-instantiated between executions. So, when subsequent executions come to the code which sets the class-level service variable to an instance of an IOrganisationService, it finds the variables already has one and that it's open.
The solution I've found easiest to implement it to have the service variable within the Execute function, rather than class-level. This has solved the problem everywhere that I've tried it since.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With