Should you be using a .NET 4.5 plugin or custom workflow activity in MSCRM 2011 Online?

Short answer: Probably not.

Continue reading


IronPython Script for Deleting Waiting CRM 2011 Workflows with an Error Code

So last week I had to clear out 1000’s of waiting workflows which had error codes in a CRM 2011 environment. I did this using an IronPython script and Determination my IronPython/CRM 2011 tool.

Its a pretty straight forward task, first deactivate the workflow (oddly, using an update call and not SetStateDynamic) and then delete the record. For those interested in performing such a task here is the full source.

import clr


import Microsoft.Xrm.Sdk
import Microsoft.Xrm.Client.Services

connection = Microsoft.Xrm.Client.CrmConnection.Parse(r'[connection string goes here]')
service = Microsoft.Xrm.Client.Services.OrganizationService(connection)

query = Microsoft.Xrm.Sdk.Query.QueryExpression('asyncoperation')
query.Criteria = Microsoft.Xrm.Sdk.Query.FilterExpression()
query.Criteria.AddCondition('errorcode', Microsoft.Xrm.Sdk.Query.ConditionOperator.NotNull)
query.Criteria.AddCondition('statuscode', Microsoft.Xrm.Sdk.Query.ConditionOperator.Equal, 10)

result = service.RetrieveMultiple(query)

for r in result.Entities:
	print r.Id
	r['statecode'] = Microsoft.Xrm.Sdk.OptionSetValue(3)
	r['statuscode'] = Microsoft.Xrm.Sdk.OptionSetValue(32)
	service.Delete('asyncoperation', r.Id)