Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


CRM 2011 Remove Notes & Attachments, Connections and Activities from an Entity

Post Author: Joe D365 |

Before we get to the CRM 2011 remove notes, connections, etc. functionality, let's keep in mind a fine print warning.

warning for CRm 2011 remove notes & attachments

All is well as long as you heed the warning, but as it so often happen, we tend to conveniently forget until long after we have developed a bunch of attributes, relationships, forms, JavaScripts, workflows and even plugins and then it hits us – we really do not need connections, notes & attachments or activities for that entity! Then why were they enabled in the first place, because Connections, Notes & Attachments and Activities are checked by default.

Now that we have done that cannot be undone, we come to the topic of this blog. How to in CRM 2011 remove Notes & Attachments, Connections and Activities from an Entity, well without doing the obvious – drop the entity and recreate it.

A couple of notes of caution before we dive into the How To's

  • This is involves customization XML modification
  • Backup your solution and data before you make any changes
  • This is a development hack and as such should be restricted to the Development Environment

Perquisites:

  • Source Organization – the organization where you have configured the entity (and enabled the Connections, Notes & Attachments and Activities)
  • Target Organization – A vanilla org, where you would like to re-create the entity, but without the Connections, Notes & Attachments and Activities. If you modify the XMl and import into the same org (the source or) it will not work
  • Some type of an XML editor would be helpful, though you can attempt to modify the XML in an text editor too

How to:

  • Export the solution containing the entity configuration from the Source Organization. This will be a zip file
  • Extract the contents of the Zip file
  • Open the Customizations.xml in an XML Editor
  • Within the root node there are two primary nodes that we will be working with
    • and
  • Once you locate these two nodes, do the changes to the child nodes as given below
  • Once you have the modified XML, replace the Customization.xml in the solution folder and zip up the files – this becomes your modified solution
  • Import the modified solution into the Target Organization (read Different organization from the one you extracted the XML)
  • Publish and validate!

To Remove Connections

Make the following XML Tags changes in the Customizations XML
Entities > Entity - Select the Entity you need > EntityInfo >
Modify <IsConnectionsEnabled>1IsConnectionsEnabled>
Set the Value from 1 to 0
EntityRelationships
Delete <EntityRelationship Name="EntityName_connections1"> node
Delete <EntityRelationship Name="EntityName_connections2"> node
Replace the Entity Name above and remove the entire node

To Remove Notes and Attachments

Make the following XML Tags changes in the Customizations XML
Entities > Entity - Select the Entity you need > EntityInfo >
Delete <HasRelatedNotes>TrueHasRelatedNotes> node
Entities > Entity - Select the Entity you need > FormXML > forms type = "main" > systemform > form > tabs > tab > labels > label > Description = "Notes"
Delete Entities > Entity - Select the Entity you need > FormXML > forms type = "main" > systemform > form > tabs > tab
This can also be done after importing the solution - Open the Entity for customization > Goto the Form and Delete the Notes Tab
EntityRelationships
Delete <EntityRelationship Name="EntityName_Annotations"> node
Replace the Entity Name and remove the entire node

To Remove Activities

Make the following XML Tags changes in the Customizations XML
Entities > Entity - Select the Entity you need > EntityInfo >
Delete <EntityMask>ActivityPointerEntityMask> node
Delete <HasRelatedActivities>TrueHasRelatedActivities> node
EntityRelationships
Delete <EntityRelationship Name="EntityName_ActivityPointers"> node
Delete <EntityRelationship Name="EntityName_Appointments"> node
Delete <EntityRelationship Name="EntityName_Emails"> node
Delete <EntityRelationship Name="EntityName_Faxes"> node
Delete <EntityRelationship Name="EntityName_Letters"> node
Delete <EntityRelationship Name="EntityName_PhoneCalls"> node
Delete <EntityRelationship Name="EntityName_RecurringAppointmentMasters"> node
Delete <EntityRelationship Name="EntityName_ServiceAppointments"> node
Delete <EntityRelationship Name="EntityName_Tasks"> node
Replace the Entity Name
This also needs to be done for any custom activities that you may have created - Replace the Entity Name and the Custom Activity Name
Delete <EntityRelationship Name="EntityName_CustomActivities">

Campaign Response is the only exception - but this is associated with only Account, Contacts and Leads.

Hope this helps. Check our Microsoft Dynamics CRM Expert blog often for helpful tips and tricks.

Happy CRM'ing!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

7 comments on “CRM 2011 Remove Notes & Attachments, Connections and Activities from an Entity”

  1. Once I recreate the entity in the donor ORG, can I export the entity and reimport into the original environment? For example,
    I export from DEV,
    import into DEVdonor without activity,
    then I export from DEVdonor can I reimport into DEV?

    1. Hi Kurt - yes, you should be able to create a new solution, add just this one entity, and export as an unmanaged solution. Then import into the other org.

  2. I followed the procedure explained but it didn't worked... not sure where I am going wrong...

  3. I need to update the entity form xml using javascript. For that I am using the xmldom method. I goggled lot but nowhere found appropriate solution.
    Please let me know is there any way to update entity form xml using javascript.
    Any help will highly appreciated.

    Thanks!

  4. Hi,

    Is there any solution to disable it on the same environment? as I want to disable it from our production environment and I don't want to delete the entity?

    Thanksm

    1. If you are a bit more daring, I have done this a lot faster with a (relatively) simple SQL script. I used the SQL profiler to examine the SQL commands CRM issued to the database when switch ON activities for a custom entity, and then reverse-engineered them to come up with my script, and, as far as I can tell so far, it worked perfectly. I haven't had to do Notes and Connections yet... Those might require an update to the MetadataSchema.Entity record... not sure, but they should be pretty simple and similar.

      Obviously this only works for those with on-premise installs (i,.e. not hand-cuffed by a cloud implementation!), and is for CRM 2011. I take no responsibility for your system getting all messed up, but... it worked for me. You should have no activities associated with the entity you are try to de-activate.

      ...hope someone finds it helpful.
      I really wish there were more "unsupported" easy fixes like this floating around the 'net.

      Cheers,
      Chris

      declare @tablename varchar(100)
      SET @tablename = 'new_testentity'

      declare @entityrel table (id uniqueidentifier)
      declare @rel table (id uniqueidentifier)

      INSERT INTO @entityrel
      SELECT EntityRelationshipId
      FROM [EntityRelationship]
      WHERE
      SCHEMANAME IN ( @tablename + '_activitypointers'
      , @tablename + '_appointments'
      , @tablename + '_emails'
      , @tablename + '_faxes'
      , @tablename + '_letters'
      , @tablename + '_phonecalls'
      , @tablename + '_tasks'
      , @tablename + '_serviceappointments'
      , @tablename + '_recurringappointmentmasters'
      )

      INSERT INTO @rel
      SELECT RelationshipId
      FROM Relationship
      WHERE
      NAME IN ( @tablename + '_activitypointers'
      , @tablename + '_appointments'
      , @tablename + '_emails'
      , @tablename + '_faxes'
      , @tablename + '_letters'
      , @tablename + '_phonecalls'
      , @tablename + '_tasks'
      , @tablename + '_serviceappointments'
      , @tablename + '_recurringappointmentmasters'
      )

      delete from RelationshipExtraCondition
      WHERE RelationshipId in (select ID from @rel)

      delete from EntityRelationshipRelationships
      WHERE EntityRelationshipId in (select ID from @entityrel)

      delete from EntityRelationshipRelationships
      WHERE RelationshipId in (select ID from @rel)

      delete from [Relationship]
      WHERE RelationshipId in (select ID from @rel)

      delete from [RelationshipIds]
      WHERE RelationshipId in (select ID from @rel)

      delete from EntityRelationshipRole
      WHERE EntityRelationshipId in (select ID from @entityrel)

      delete from EntityRelationship
      WHERE EntityRelationshipId in (select ID from @entityrel)

      delete from [EntityRelationshipIds]
      WHERE EntityRelationshipId in (select ID from @entityrel)

PowerObjects Recommends