I recently acted as a technical reviewer for a new book; Microsoft Dynamics CRM 2011 Cookbook by Dipankar Bhattacharya. This book is now available from Packt Publishing so I thought I would publish a short review. (Note: I’m not paid by Packt for this role but I do get a free book).
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.
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)
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.