The record could not be deleted because of an association

Dear Dynamics 2011 developers, here is my first article about Microsoft CRM development. I hope to write more while I follow the development of a new CRM project.

Since I’m a beginner in this field, the first articles will be about problems I’m facing in setting up and configuring Dynamics.

So here it comes, after trying to write calendar rules of an equipment, failing miserably, it happened we were not able to view the service calendar and other service related entities including the equipment owner of the corrupted calendar. Since we’re in early development we decided to delete the equipment and recreate it, but surprise surprise, our friend CRM won’t allow it.

So we faced the creepy message: “The record could not be deleted because of an association”.

[ad]

Nothing to worry about if you know who’s keeping a reference to this entity…obviously that’s not our case.

Since we needed to start practicing with CRM web services, we decided to develop a small tool to recursively enumerate all the references to our “to be deleted” entity, and eventually delete them.

This tool serves also as a good example of how to handle CRM web services, enumerate entities and their metadata, CRUD operations on entities, …

In the following download link you’ll find sources and binaries.

XrmTools (976 downloads)

Note: before running the tool you need to configure the connection to your CRM organization editing the app.config file. The operation should be straight forward.

Feel free to provide feedback commenting this article.

Regards

Leave a Reply

Your email address will not be published. Required fields are marked *