locked
Custom entity import issue RRS feed

  • Question

  • Hi all,

    I work on a CRM 4 server for my company and I have an issue about customizations import.
    I customized many entities and I have several custom entities as well. All changes are done on a test server and as soon as the customizations are tested, I export those customizations then I import them on the production server.

    Everything has worked perfectly for several weeks but yesterday I got an error importing new customizations on my production server.

    Here is my software configutation: CRM 4 (Rolup 3), Win Server 2003 Enterprise Edition SP2, SQL Server 2005

    Here is the message I got when I clicked on the upload button:

    Either the file could not be uploaded, or this is not a valid Customization file

    • First, I did it a second time to be sure. It didn't work.
    • Then I started to think my brand new custom entity was the problem. Indeed, when I select everything but this new entity, customizations are imported properly. By the way, I need this custom entity so impossible for me not to import it...
    • Then, I exported that entity from my test server and I tried to re-import it on the test server itself but it didn't work! (that's weird, isn't it?)
    • Finally, I checked the Trace file on my test server and here is what I found:

    ValidateImportDocument hit exception. Message: The element 'form' has invalid child element 'events'. Details: System.Xml.Schema.XmlSchemaValidationException: The element 'form' has invalid child element 'events'.

    Obviously, this error is from the XML parser. It means the file is not well formed. I opened the XML file and I found the node "<events>" which is a child of the node "<form>".
    Here is how the file is formed:

    ....<forms>
      <entity name="new_resourceallocated">
        <form type="main">
          ....
          <events>
            <event name="onload" application="false" active="false">
              <script><![CDATA[]]></script>
              <dependencies />
            </event>
            <event name="onsave" application="false" active="false">
              <script><![CDATA[]]></script>
              <dependencies />
            </event>
          </events>
        </form>
      </entity>
    </forms>....

    I checked the other entities XML files and they are formed like this one and they can be imported...
    When I remove the node "<events>", I can import this entity. So I tried to re-export it then re-import it but this "<events>" node came back and the issue came back too...


    What is wrong with my custom entity? Although the XML file is formed like any other entity, this customization is considered as a non valid customization file...
    Any idea?

    Thanks in advance,

    Franck.

    • Edited by Advanced 365 Friday, May 8, 2009 9:00 AM layout reason
    Friday, May 8, 2009 8:57 AM

Answers

  • Hi Rob,

    today I had the same problem.

    We have an upgraded crm organisation on crm 4 enterprise with rollup 2. The system was upgraded from crm 3.
    The trigger for our problem was simple: somebody inserted a script into the OnLoad() of a custom entity. Since then it was impossible to import this entity in any other system.

    The insert of this script produced following section in the customization export

    ...
    </tabs>              
    <externaldependencies>
      <dependency id="notescontrol" />
    </externaldependencies>                 
    <events>
     <event name="onload" application="false" active="true">
        <script><![CDATA[some script in here;]]></script>
           <dependencies />
     </event>
    </events>
    ...
    However, this section is invalid. But not the events node is wrong. The node <externaldependencies> is at the wrong location. This node has to be after the events node.

    There are two possibilities:

    - if you need this 'Non-Event Dependency': go to the entitys form -> form settings -> 'Non-Event Dependency' -> Remove the dependent field(s) -> Save and Publish -> Add the fields -> Save and Publish

    This produces the correct section in the customizations

     ...
     </tabs>
     <events>
      <event name="onload" application="false" active="true">
       <script><![CDATA[some code;]]></script>
        <dependencies />
      </event>
     </events> 
     <externaldependencies>
      <dependency id="notescontrol" />
     </externaldependencies>
    </form>
    ...
    - if you do not need the dependencies: see above, but don't add the fields again


    HTH

    Christoph
    • Proposed as answer by ckeller Wednesday, August 19, 2009 12:16 PM
    • Marked as answer by Donna EdwardsMVP Wednesday, August 26, 2009 8:38 PM
    Wednesday, August 19, 2009 12:14 PM

All replies

  • hi did u try checking log file.

    sometimes back i too faced one such issue.
    wat happened when i tried to import customisations from one environment(test) to other environment(actual) one of my custom entity reported error..
    wat happened is that my custom entity has 1 attribute of type int on both test and actual environments. but while makin changes on my test environment i realised that the specified attribute should be nvarchar and not int. so i changed the attribute. but forgot to change it in actual environment. so when i tried to import the test envrnment customisation to actual one... crm din allow me to import.
    Friday, May 8, 2009 9:11 AM
  • Hi,

    The thing is I can't even import my customization on the same server... I should have an error before exporting my customizations.
    Which log file are you talking about? I checked the Trace file already.

    Thanks.
    Friday, May 8, 2009 9:18 AM
  • well..
    i too was sayin abt same server..
    actually we had made two different organisations as two different environments on same server...

    while importing data from one org to another i faced that prob
    Friday, May 8, 2009 9:34 AM
  • HI Rob

    Do you have any jobs running against this enity on the test environment like duplicate detect jobs or have duplicate detection jobs on the test server running?


    Tiaan van Niekerk http://crmdelacreme.blogspot.com Skype:tiaan.van.niekerk1
    Friday, May 8, 2009 9:36 AM
  • Hi Tiaan,

    Like for all my entities "Enable Duplicate detection" is ticked but no workflow against this entity.

    Nobody got an issue with an invalid xml file that can't be imported on the server from which it was exported?

    Again, when I remove the node <events> it works... I don't get it.

    Thanks again for your help!

    Friday, May 8, 2009 10:33 AM
  • Hi all,

    It still doesn't work and when I export this entity, I still have to edit the XML file before importing it (even on the same server / business unit).

    I noticed my first post was quite long and confused so I will sum up the issue about my custom entity:

    • There is no javascript event & the entity works properly
    • It can't be imported (even on the same server) => error message: "Either the file could not be uploaded, or this is not a valid Customization file "
    • In the Trace file, the customization.xml raises an error whereas it is formed exactly like all the other entities: "ValidateImportDocument hit exception. Message: The element 'form' has invalid child element 'events' "
    • It works if I remove the node "<events>" from the xml file.
    The xml editing is just a temporary solution because the next time I will try to export / import I will have the same xml error...

    Thanks in advance,
    Monday, May 18, 2009 3:21 PM
  • Hi Rob,

    today I had the same problem.

    We have an upgraded crm organisation on crm 4 enterprise with rollup 2. The system was upgraded from crm 3.
    The trigger for our problem was simple: somebody inserted a script into the OnLoad() of a custom entity. Since then it was impossible to import this entity in any other system.

    The insert of this script produced following section in the customization export

    ...
    </tabs>              
    <externaldependencies>
      <dependency id="notescontrol" />
    </externaldependencies>                 
    <events>
     <event name="onload" application="false" active="true">
        <script><![CDATA[some script in here;]]></script>
           <dependencies />
     </event>
    </events>
    ...
    However, this section is invalid. But not the events node is wrong. The node <externaldependencies> is at the wrong location. This node has to be after the events node.

    There are two possibilities:

    - if you need this 'Non-Event Dependency': go to the entitys form -> form settings -> 'Non-Event Dependency' -> Remove the dependent field(s) -> Save and Publish -> Add the fields -> Save and Publish

    This produces the correct section in the customizations

     ...
     </tabs>
     <events>
      <event name="onload" application="false" active="true">
       <script><![CDATA[some code;]]></script>
        <dependencies />
      </event>
     </events> 
     <externaldependencies>
      <dependency id="notescontrol" />
     </externaldependencies>
    </form>
    ...
    - if you do not need the dependencies: see above, but don't add the fields again


    HTH

    Christoph
    • Proposed as answer by ckeller Wednesday, August 19, 2009 12:16 PM
    • Marked as answer by Donna EdwardsMVP Wednesday, August 26, 2009 8:38 PM
    Wednesday, August 19, 2009 12:14 PM
  • Hi Rob

    The reason for your problem is maybe related to not having a production and test environment who is exactly the same, regarding entities.

    The reason i are mentioning this is because most people think that when you import a customization (let's say a entity), the customization you import will replace the whole entity, which is not the fact. The only thing who will be imported is the difference between the existing entity, and the entity you are importing.

    For example: If you have an entity who has an attribute called new_myattribute in the production environment, and now you import the same entity from the test environment, but there you have either deleted the new_myattribute attribute or/and created other attributes, making new mappings etc. the final product will be:
    - you will keep the new_myattribute
    - new attributes will be imported
    - existing mappings will still exist
    - new mappings will be created.

    My point is: Be sure to have exactly the same entities in both the production, and test environment.

    //Henrik
    Saturday, August 22, 2009 12:05 AM