Home > MS CRM 4.0 > Change Entity Ownership

Change Entity Ownership


When you create a new Entity within MSCRM you have a choice to make regarding the ownership of that Entity.

From the MSCRM 4.0 Help File:

In the Ownership list, select either:

  • User
    Records for this entity can be owned by individual users. For example contact records are set to User.–   OR –
  • Organization
    Records for this entity are used for reference by all Microsoft CRM users, and so are not owned by individual users. For example, product records are set toOrganization.

 

While attending an MSCRM Troubleshooting class last week, I learned something that isn’t readily apparant when you are creating enties:

In order for a custom entity to be available to the CRM Workflow module, it must be created with an ownership of User.

This was news to me, and unfortunately, unwelcome news. I had just created 12 custom Entities that had a combined total of over 100 Attributes and Relationships out the wazzoo. Since you can’t change the Ownership type after creation, I was looking at spending a few hours deleting my existing Entities and recreating them from scratch.

And after thinking about it, I understand why the ownership requirement for workflow exists, I just wish it had been better documented.

Anyway, I was thinking ( mustly hoping ) that there just had to be a way to alter the definition of the Entity without having to manually recreate it.  It turns out, there is, but it is a bit of work.

 

The following information is provided as-is, without any warranty, either expressed or implied.

It is probably unsupported by Microsoft as well.

Use this information for reference and as a last-resort.

 

How Entities are Organized

With the exception of three Attributes, the tables of a User Owned Entity and an Organizational Owned Entity are exactly alike. The following table contains the Attributes created when you create both types of Entities. Those in bold are specific to that Ownership type.

Organization Ownership User Ownership
Name Type Name Type
createdby lookup createdby lookup
createdon datetime createdon datetime
createdon datetime createdon datetime
modifiedby lookup modifiedby lookup
modifiedon datetime modifiedon datetime
new_2blankoid primarykey new_2blankoid primarykey
new_name nvarchar new_name nvarchar
statecode state statecode state
statuscode status statuscode status
organizationid lookup ownerid owner
owningbusinessunit lookup

So, how do we convert an Entity from one ownership type to another as cleanly as possible and keeping the destruction to a minimum?  I’ve successfully performed the following steps and have seen no side effects.

Step 1: Back up your CRM databases.

Step 2: Export All Customizations.

Even though you may only be working with one or two Entities, I feel it is best that all Entities be included in the export to ensure that we don’t miss anything.

Step 3: Make a backup copy of your exported customizations.

Just in case your edits do not work as planned.

Step 4: Delete the custom entity that needs to be reassigned Ownership.

Sorry, there is just no way around this step. The Import Customizations process only adds data and changes, it will not delete anything, and we must delete attributes.  That means data loss.

Step 5: Open the exported customizations in WordPad.

Or whatever your favorite XML editor is.  Just remember how picky CRM 3.0 is about its XML format.  Personally, I use WordPad because it doesn’t introduce additional line feed characters that so offend CRM.

Note: Steps 6 – 8 will be repeated for each Entity that needs to be altered.

Note 2: DO NOT attempt to copy the following XML from this blog and insert it into your CRM Export file. It will break the file and you will be unable to import it.  I would suggest Exporting a single Entity with User Ownership and have that open in a separate WordPad instance to copy the code from.

Step 6: Change the ownership type.

Find the following code:

<OwnershipTypeMask>OrgOwned</OwnershipTypeMask>
And replace it with the following:

<OwnershipTypeMask>UserOwned</OwnershipTypeMask>

Step 7:  Remove the Organization Attributes and Insert the User Attributes

DELETE THE FOLLOWING CODE

<attribute PhysicalName=”OrganizationId”>
<Type>lookup</Type>
<ValidForReadApi>1</ValidForReadApi>
<ReferencedEntityObjectTypeCode>1019
</ReferencedEntityObjectTypeCode>
<Description>Unique identifier for the organization</Description>
</attribute>
INSERT THE FOLLOWING CODE

<attribute PhysicalName=”OwnerId”>
<Type>owner</Type>
<IsNullable>0</IsNullable>
<ValidForCreateApi>1</ValidForCreateApi>
<ValidForUpdateApi>1</ValidForUpdateApi>
<ValidForReadApi>1</ValidForReadApi>
<IsLogical>1</IsLogical>
<DisplayMask>ValidForAdvancedFind|ValidForForm|ValidForGrid
</DisplayMask>
<Description>Owner Id</Description>
</attribute>
<attribute PhysicalName=”OwnerIdDsc”>
<Type>int</Type>
<IsNullable>0</IsNullable>
<ValidForReadApi>1</ValidForReadApi>
<IsLogical>1</IsLogical>
<AttributeOf>OwnerId</AttributeOf>
<XmlAbbreviation>dsc</XmlAbbreviation>
<Description />
</attribute>
<attribute PhysicalName=”OwnerIdName”>
<Type>nvarchar</Type>
<Length>320</Length>
<IsNullable>0</IsNullable>
<ValidForReadApi>1</ValidForReadApi>
<IsLogical>1</IsLogical>
<AttributeOf>OwnerId</AttributeOf>
<XmlAbbreviation>name</XmlAbbreviation>
<IsSortAttribute>1</IsSortAttribute>
<Description>Name of the owner</Description>
</attribute>
<attribute PhysicalName=”OwnerIdType”>
<Type>int</Type>
<ValidForCreateApi>1</ValidForCreateApi>
<ValidForReadApi>1</ValidForReadApi>
<IsLogical>1</IsLogical>
<DisplayMask>ObjectTypeCode</DisplayMask>
<AttributeOf>OwnerId</AttributeOf>
<XmlAbbreviation>type</XmlAbbreviation>
<Description>Owner Id Type</Description>
</attribute>
<attribute PhysicalName=”OwningBusinessUnit”>
<Type>lookup</Type>
<ValidForReadApi>1</ValidForReadApi>
<ReferencedEntityObjectTypeCode>10
</ReferencedEntityObjectTypeCode>
<Description>Unique identifier for the business unit that owns the record</Description>
</attribute>
<attribute PhysicalName=”OwningUser”>
<Type>lookup</Type>
<ValidForCreateApi>1</ValidForCreateApi>
<ValidForUpdateApi>1</ValidForUpdateApi>
<ValidForReadApi>1</ValidForReadApi>
<ReferencedEntityObjectTypeCode>8
</ReferencedEntityObjectTypeCode>
<AggregateOf>OwnerId</AggregateOf>
<Description>Unique identifier for the user that owns the record.</Description>
</attribute>

Step 8: Change the form fields from Organization to User.

DELETE THE FOLLOWING

<field name=”organizationid” requiredlevel=”na”>
<displaynames>
<displayname description=”Organization Id” languagecode=”1033″ />
</displaynames>
</field>
INSERT THE FOLLOWING

<field name=”ownerid” requiredlevel=”na”>
<displaynames>
<displayname description=”Owner” languagecode=”1033″ />
</displaynames>
</field>
<field name=”owningbusinessunit” requiredlevel=”na”>
<displaynames>
<displayname description=”Owning Business Unit” languagecode=”1033″ />
</displaynames>
</field>

Step 9: Save and close the Export file

Step 10: Import the modified Exported customizations

Step 11: Publish All Customizations

Do this before you do anything else with the system as it will ensure that all of the data is completely replication throughout the CRM 3.0 system.

Finished.

Just to make sure everything is fine within the CRM 3.0 system, I perform the additional steps:

Step 12: Add a temporary Attribute to the altered Entity.

This is really just to make sure that the CRM Entity modification process still functions as expected.

Step 13: Add that Attribute to the data entry Form.

Step 14: Publish the Entity

Step 15: Create and save a new record for the altered Entity.

Step 16: Delete the temporary Attribute from the Entity.

Step 17: Publish the Entity.

Really Finished.

 

 

Advertisements
Categories: MS CRM 4.0
  1. CRMbrenden
    June 6, 2011 at 4:38 pm

    Is this process valid for CRM 2011?

    • July 4, 2011 at 11:57 am

      I never tried in 2011 , will update the post once i give a tri in CRM 2011

  2. September 1, 2011 at 1:16 pm

    Perfect, only missed removed relationships with organization or user, find by “entityrelationships”.

    Tanks

    • salman.malik373@gmail.com
      October 24, 2012 at 2:26 am

      Did you find the following tags in crm 2011
      field name=”organizationid” requiredlevel=”na”
      displaynames
      displayname description=”Organization Id” languagecode=”1033″
      displaynames
      field

      • October 26, 2012 at 12:32 pm

        Hi ,
        I did not try this process in 2011 , I will test ti and will reply back with my findings.

  3. Mauro
    May 21, 2012 at 10:10 am

    I must change ownership for the product Entity; what do you suggest me?
    thanks

  4. salman.malik373@gmail.com
    October 24, 2012 at 2:21 am

    I Can not find the following code in CRM 2011 Customizations.xml

  5. salman.malik373@gmail.com
    October 24, 2012 at 2:23 am

    Not found in CRM 2011 exported xml

  6. salman.malik373@gmail.com
    October 24, 2012 at 2:25 am

    field name=”organizationid” requiredlevel=”na”
    displaynames
    displayname description=”Organization Id” languagecode=”1033″
    displaynames
    field

  7. Chris
    September 26, 2013 at 5:08 am

    Has anyone been able to do this successfully on CRM 2011 (Online). If so, could you let me know please?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: