locked
How to fix a broken custom entity. RRS feed

  • Question

  • Well, I am officially an idiot.

    I decided to try to brute force a name change of an attribute on a custom entity.  This attribute is the ID of a related entity. 

    I did this by exporting the custom entity, doing a replace all to change the 4 instances of that attribute name in the XML, and then reimporting it.  

    Reimporting worked. Publishing did not...errored out. 

    I thought I was fine and that all I needed to do was reimport the original export, but even after doing that, I still can't publish. 

    Everything looks right when I look at attributes and form, but still can't publish.  Nothing is being logged to the Event Viewer either.

    Any ideas on this? I can't afford to delete the entity...too much data would be lost.

    Clif

    Wednesday, January 26, 2011 4:18 PM

Answers

  • Try this but make sure you backup your database.

    Locate your entity's related row/s in the OrganisationUIBase table in the CRM database, you can do this by searching on the FormXml field with somehting like

    I've assumed the lookup field was on the opportunity.

    SELECT * FROM         OrganizationUIBase
    WHERE     (FormXml LIKE '%name="Custom_Entity_Name"%')

    If 2 rows return then you can delete the row that has the InProduction value set to true. If only one row returns then set the InProduction value to false. Then restart IIS or recycle the CRMAppPool, finally select to publish the entity.


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Check out the CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM Forum Guidance on how to Help Us Help You
    Friday, January 28, 2011 4:57 PM
    Moderator

All replies

  • When you say the 'attribute is the ID of a related entity' are you referring to it baing a lookup field?

    If so, go to the form designer and remove the lookup from the form and publish the form. Check if this works and then go back and add the lookup field back to the form.


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Check out the CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM Forum Guidance on how to Help Us Help You
    Wednesday, January 26, 2011 4:59 PM
    Moderator
  • Yes.  There is a relationship between contact and this custom entity.  The field that I was trying to rename is a lookup field.

    I removed it from the form, saved, and tried to republish the entity but it still errors :(

    Wednesday, January 26, 2011 5:09 PM
  • Hi Clifton,

     

    Please tell me, what's the version of the CRM you were using, as well the roll-up version. You can recover a crashed entity, but it takes a lot of SQL + XML effort to fix it. Can you describe, more specifically, the scenario of how it crashed? Thank you.


    Cornel Croitoriu - Senior Software Developer - http://bizforward.blogspot.com
    Wednesday, January 26, 2011 5:52 PM
  • CRM 4.0 Update Rollup 8. 

    I need to do whatever it takes.  I can't believe they are fragile like this. 

    Wednesday, January 26, 2011 6:35 PM
  • It's not about being fragile or not. Thing is that a lot of constraints are being applied on customization import to keep the database integrity. First of all, enable the CRM Tracing (Start > Run > regedit.exe > [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM] > and add here TraceEnabled and TraceRefresh - both dword values, with value 1). After this, retry the customizations import, check the error in the log, and post it here. I've experienced & fixed several scenarios concerning customization imports and I'd be glad to help you.
    Cornel Croitoriu - Senior Software Developer - http://bizforward.blogspot.com
    Wednesday, January 26, 2011 6:45 PM
  • Cornel,

    Here are the results of the trace.  I don't see anything that looks applicable in them, but that may be because I don't know what I'm looking for. 

    http://dl.dropbox.com/u/5975142/LUCRMWEB01-w3wp-CRMWeb-20110127-1.log

    The entity in question is named "DocumentReceived".  I don't see any reference to that in the logs.

    Thanks for your help!
    Clif

    Thursday, January 27, 2011 4:28 PM
  • Grrr... I had the exact same issue few days ago. Not fun. I did everything and didn't work. At the end, I did a restore of the _MSCRM database.
    Thursday, January 27, 2011 4:34 PM
  • Anyone know how to fix this?

    Restoring from backup is not really an option.
    Friday, January 28, 2011 3:30 PM
  • Try this but make sure you backup your database.

    Locate your entity's related row/s in the OrganisationUIBase table in the CRM database, you can do this by searching on the FormXml field with somehting like

    I've assumed the lookup field was on the opportunity.

    SELECT * FROM         OrganizationUIBase
    WHERE     (FormXml LIKE '%name="Custom_Entity_Name"%')

    If 2 rows return then you can delete the row that has the InProduction value set to true. If only one row returns then set the InProduction value to false. Then restart IIS or recycle the CRMAppPool, finally select to publish the entity.


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Check out the CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM Forum Guidance on how to Help Us Help You
    Friday, January 28, 2011 4:57 PM
    Moderator
  • On line 869 is your error:

    Stack Trace Info: [NullReferenceException: Object reference not set to an instance of an object.]
       at Microsoft.Crm.ObjectModel.OrganizationUIService.LabelLoaderPublished.LoadMetadataLabel(Int32 entityType, String attributeName, ExecutionContext context)

    I would look in the StringMap table, the MetadataSchema.Attribute table (look in the MetadataSchema.Entity table first for the objecttypecode) and the MetadataSchema.LocalizedLabel for references to the old attribute name and replace those. Filter on objecttypecode!

    You will have to check the Views as well (ORGNAME_DocumentReceived and FilteredORGNAME_DocumentReceived in your case) for inconsistent column names (inconsistent with your attribute name change).

    Friday, January 28, 2011 5:11 PM
  • Thank you for the tips, I'll check this out as soon as possible.  If anyone else has any knowledge of this, please let me know :)

    Friday, January 28, 2011 8:44 PM