Menu

Override "name" field and change parent class on a custom class

1 day ago
4 hours ago
  • Guillaume Vaillant

    Hello,

    I have created a custom class "TOTO" that inherits from PhysicalDevice.

    My issue is that on the TOTO class I need the "name" field to be optional, which is not the case with the PhysicalDevice class (where name is mandatory).

    First question: Is it possible, within my class, to override the inherited "name" attribute to make it optional? If so, what is the correct way to do this in the XML data model definition?

    Second question: I would actually like to change the parent class to use a different one, so I have more freedom over the available fields. But if I change the parent class while I already have data stored in my TOTO class, what happens to that existing data? Is there a risk of losing it, and what is the recommended way to handle this migration?

    Thanks in advance for your help.

     
  • Vincent @ Combodo

    Hi Guillaume,
    It's not possible to overwrite the parent field definition in a child class. I wrote a post on this already as well as a new wiki page somewhere...
    If you change the parent class while you have existing data, you will loose them. CSV export them before, delete them, upgrade your itop, reload the data.
    If you have a lot of relationships already in place, that export becomes complex, with many classes to exports...

     
    👍
    1
  • Jeffrey Bostoen

    Jeffrey Bostoen - 5 hours ago

    You could consider hiding the field and setting a default value. This default value may be visible in certain lists though.

     
  • Umesh Kumar

    Umesh Kumar - 4 hours ago

    Hello @glajarige

    As you see that PhysicalDevice class is child FunctionalCI
    so you can redefine that field in custom extension or in core files you can file FunctionalCI class where you can change value of name feild is_null_allowed true from false

    this will be helpful

    <class id="user-content-FunctionalCI" _delta="must_exist">
    <fields>
    <field id="user-content-name" xsi:type="AttributeString" _delta="redefine">
    <sql>name</sql>
    <default_value>
    <is_null_allowed>true</is_null_allowed>
    </default_value></field>
    </fields>
    </class>

     

Log in to post a comment.