Sunday, July 19, 2009

Removing Activities after entity has been created in CRM 4.0

Recently, I've started working on CRM bit seriously. Basically, my areas of interest includes .Net and DHTML and lot many other technologies. But CRM was never there in my list till last January. After taking a long break [Trust me anything beyond few hours away from computers, is LONG for me], in January, I realized, that I needed to give it a shot and since then the journey has been AWESOME!!! And here one of the problem I solved recently while helping out someone. If you have worked with CRM, you know how it makes your life really interesting some times. Like you can not disable the relationship between a custom made entity and notes/activities once you have created it. I am damn sure, it was some pressing dead line or/and regression testing would have shown some strange behavior on removal of the same so dev team might have decided to lock it permanently once it is created. And as usual sometimes you might wanna get rid of Activities from your custom relationship as a result of design change or maybe just for a challenge... in that case... here is a hack that might come handy. Only limitation is you will have to delete the entity and then recreate it after a few changes in the customization xml. So if you have any existing data, this is not what you should be doing[You should be looking for the guy or gal who designed your solution right?].

Standard ToCs applies and... yes.. you get me right... if something goes wrong I DO NOT Take any responsibility of any kind of damage that might occur due to this little hack.

Here is what I did to remove activities from my custom entity.
- Export the customization.
- Extract and open the customization xml.
- Open the xml file in Visual Studio or any other xml/text editor of your choice.
- Change
<HasRelatedActivities>True</HasRelatedActivities>
to
<HasRelatedActivities>False</HasRelatedActivities>
- Remove
<EntityMask>ActivityPointer</EntityMask>
- Remove ActivityPointerRegardingName from <DisplayMaskElement>
- Remove following <EntityRelationship> elements.
- _ActivityPointers
- _Appointments
- _Emails
- _Faxes
- _Letters
- _PhoneCalls
- _ServiceAppointments
- _Tasks

- Save the xml file.
- Import and publish the customization xml file.

Let me know how it goes, as I would love to hear whether it worked for you or not.

No comments: