IronPython CRM 2011 Script for Copying Forms

So I’ve got an entity which has two very similar and very long forms. I made changes to one form which I needed to replicate on the other. I didn’t want to do that manually because that seemed like a very tedious and longwinded piece of work. So instead I used some code.

I did this using an IronPython script and Determination my IronPython/CRM 2011 tool.

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

clr.AddReference('Microsoft.Xrm.Sdk')
clr.AddReference('Microsoft.Xrm.Client')

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.Update(r)
	service.Delete('asyncoperation', r.Id)

Microsoft Dynamics CRM 2011 Scripting Cookbook

8826EN

The friendly folks over at Packt Publishing recently sent me a copy of Microsoft Dynamics CRM 2011 Scripting Cookbook by Nicolae Tarla. I have worked for them in the past as a technical reviewer (unpaid) and they asked me to review this book for them.

I really enjoyed Nicolae’s work, it’s a great book and I have no reservations about recommending this to others. It really is a fantastic piece of work.

Continue reading

Simplicity – A Handy URL Tool for MSCRM 2011

I often have a situation where I have a record ID and need to open the record form, and the opposite where I have the record form open and I need the ID. Usually I can do both of these by messing around with the URL of a form, however that can be quite longwinded.

Untitled

To that end I have created Simplicity, a small tool which performs two basic actions:

1. Stripping the IDs out of MSCRM record URLs – useful when have a record open and you want to know its decoded ID.
2. Building a URL to open a record – useful when you have the ID and you want to open the form in CRM.

License under Creative Commons Attribution 3.0 and available for download here.

Determination – An IronPython Script Tool for MSCRM 2011

Determination is a light weight IronPython scripting tool specifically setup for MSCRM 2011.

d1

Determination is licensed under Creative Commons Attribution 3.0.

You can download Determination here. To run; download, unblock the zip, unzip the zip and run the application.

Continue reading

CRM 2011 Export Unmanaged Solutions Programatically

A couple of day’s ago I was asked to export all the unmanaged solutions from an environment for the purposes of backup. There was more than a few so to avoid having to do them all manually I hacked out this code; which when given a service and directory will export all the unmanaged from the environment.

Continue reading