locked
Removing a custom attribute that is *now* a system attribute RRS feed

  • Question

  • Interesting situation came up.  I was editing the customizations.xml file for the Address entity and was adding some custom attributes.  Somehow, through forgetfulness or whatever, I forgot to include the <IsCustomField>1</IsCustomField> tag.  That ended up turning the custom attribute into a system attribute.  That effectively locks the attribute in place, so I'm unable to do any edits, change it back to a custom attribute or even delete it.

    Question is: how does one fix the problem?  My first reaction is to go into the DB and issue a "ALTER TABLE dbo.addressentitybase DROP COLUMN customfield" SQL command.  However, I've got a league of co-workers who are screaming "Don't do that!  Never touch the database!  Microsoft won't support that!"  They are of the opinion there's another way to either remove the attribute or fix it programatically or through some other esoteric method.  I can't find anything on the subject.

    So if you accidently import a custom attribute as a system attribute, how do you correct it?

    Wednesday, October 14, 2009 4:49 PM

Answers

  • If Hassan's suggestion doesn't work (though I think it will), you've got 2 options:
    1. Leave the attribute as is - I assume it'sw not doing any harm at the moment ? The problem with this is you may run into future problems when upgrading CRM
    2. You'll need a SQL solution, which is unsupported, but don't directly drop the column (you'll cause havoc). Instead, change the IsCustomField column in the MetadataSchema.Attribute table for your attribute to reset it.
    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
    Wednesday, October 14, 2009 6:37 PM
    Moderator

All replies

  • First 2 questions!

    Have you tried editing the xml again and add the missing part and import again?
    Is restoring the db to an earlier state before the import impossible?

    If both of those are not working for you then the following might.!

    Personally I do not recommend editing the DB directly, specially not if you are deleting stuff, but minor changes like the one I am proposing might be ok.

    This is something microsoft will ofcourse not support, and Take a backup of the db before doing this.

    MetadataSchema.Attribute table contains information on all attributes, if you feel confident enough to edit the xml file directly then I suppose this change should not be to bad...


    There is a column in this table called IsCustomField, Find your attribute and put this field to true. This should do it for you.

    Wednesday, October 14, 2009 4:57 PM
  • Hi,

    Haven't tried this but you will need to do the following.

    1- Export the customizations again as customizations.xml file. 
    2- Edit the file to fix the mistake. (by adding the iscustomfield tag to the field).
    3- Re-import the XML back into the system.

    This should resolve the issue.


    Hassan.


    Hassan Hussain | http://hassanhussain.wordpress.com/ | http://www.mscrmvirtualusergroup.com/
    • Proposed as answer by Hassan Hussain Wednesday, October 14, 2009 4:59 PM
    • Unproposed as answer by C_Campbell Thursday, October 15, 2009 5:06 PM
    Wednesday, October 14, 2009 4:59 PM
  • If Hassan's suggestion doesn't work (though I think it will), you've got 2 options:
    1. Leave the attribute as is - I assume it'sw not doing any harm at the moment ? The problem with this is you may run into future problems when upgrading CRM
    2. You'll need a SQL solution, which is unsupported, but don't directly drop the column (you'll cause havoc). Instead, change the IsCustomField column in the MetadataSchema.Attribute table for your attribute to reset it.
    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
    Wednesday, October 14, 2009 6:37 PM
    Moderator
  • Adding the field in the XML schema to have <IsCustomField> and reimporting the customization won't work.  By that time, the attribute has already been created in the base table.  Upon reimport, CRM goes through it's checklist of things it can update and not update.  The system attribute check is one of the first things that is validated, so the import skips the update on that attribute.

    This happened on one of our development systems, so it isn't a big deal.  For example, exporting the entity and editing the XML to have <IsCustomField> and importing it into any other environment works just fine... it's just a total pain to remember to do this every time.  Another good thing is that I caught it just after it happened so there weren't any relationships added based on these attributes.  No data has been entered against these attributes either.  If there were any data or relationships, I wouldn't think of dropping the columns.

    I'll take a quick look at David's suggestion below on the MetadataSchema.Attribute table and see how that works out.  Flipping the flag should do the trick.

    Wednesday, October 14, 2009 9:09 PM