Copying Attributes from one Entity to Another


I have been asked many times, “If I customize this entity can I simply copy the attributes to another entity or do I need to create them from scratch?”.  The answer has been “No, there is no feature in CRM to do this.  You need to create them again”.  So I decided to dig in a bit and figure this out.  I came across the following post from CRM MVP Matt Wittemann which discusses copying the attribute portion of the entity.  There’s the answer.  While a pretty easy solution, it is not as easy as you would expect, unless you know the trick.  :)  So in this post I will show how to copy all the address attributes from the Account entity to a custom entity.

  1. Export the Account entity customizations.

  2. Use an xml viewer (I use Visual Studio 2008) to find the entity attributes.  Ctrl+f using <attributes> usually does the trick or simply collapse the elements under Account.

  3. Copy the the address attributes (I excluded the AddressId primary key values for both Address1 and Address2 as that didn’t seem logical to copy to a new entity – don’t want to break anything here!).  If you are lazy (and I am sure many of you are) I have posted the address attributes here.

  4. Paste the address attributes into the desired entity.  Make sure insert them within the <attributes> section!

  5. Here comes the trick(s).  In this example we are copying system attributes (not custom attributes) so you will need to update each attribute to replace <IsLogical>1</IsLogical> with <IsCustomField>1</IsCustomField>.

    • If it is not a system attribute the <IsLogical>1</IsLogical> value may not exist.  In that case simply add <IsCustomField>1</IsCustomField> after <ValidForReadApi>1</ValidForReadApi>.

    • If the custom attribute is a picklist, each picklist has 2 attributes (<Type>picklist</Type> and <Type>virtual</Type>).

      • Update the <Type>picklist</Type> attribute to either replace <IsLogical>1</IsLogical> with <IsCustomField>1</IsCustomField> or simply add <IsCustomField>1</IsCustomField> after <ValidForReadApi>1</ValidForReadApi>.

      • Update the <Type>virtual</Type> attribute by adding <IsCustomField>1</IsCustomField> after <ValidForReadApi>1</ValidForReadApi> retaining <IsLogical>1</IsLogical>.

  6. Import the modified entity customizations into CRM.

  7. You will now have all the address attributes listed within the entity attributes that you can add to the form.

I have created a custom Partner entity (as seen above) following this process and posted the Partner entity.xml here as an example.  Note: The entity .xml contains the form (including OnLoad, OnSave and OnChange events), views, attributes, and relationships.  In this Partner example I have included the OnLoad and Country OnChange events to make the hierarchical picklist work.  For more details on hierarchical State / Country picklists check out this post.

-Eric Boocock

Comments (2)

  1. I recently had the need to add hierarchical state and country picklists to a custom entity. I had configured

  2. I have been asked many times, “If I customize this entity can I simply copy the attributes to another