Menu

New custom field not visible despite presentation definition

Kai Karger
2022-05-16
2022-05-16
  • Kai Karger

    Kai Karger - 2022-05-16

    hi,

    I added a new field and the field is created in the database as seen in the attachment.

    When adding the presentation tags it has no effect. The new field does not show up. Here is my datamodel file for the extension:

    <?xml version="1.0" encoding="UTF-8"?>
    <itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.6">
      <classes>
         <class id="Incident">
                <fields>
                    <field id="classification" xsi:type="AttributeEnum" _delta="define">
                        <values>
                            <value>Non-critical deviation</value>
                            <value>Critical deviation</value>
                            <value>Security leak</value>
                            <value>Data leak</value>
                            <value>Complaint</value>
                            <value>GDPR</value>
                        </values>
                        <sql>classification</sql>
                        <default_value/>
                        <is_null_allowed>true</is_null_allowed>
                        <display_style>list</display_style>
                    </field>
                    <presentation>
                        <details>
                        <items>
                            <item id="classification" _delta="define">
                                <rank>60</rank>
                            </item>
                        </items>
                        </details>
                    </presentation>
                </fields>
         </class>
      </classes>
    </itop_design>
    

    I also tried to copy and paste the whole presentation structure from itop/datamodels/2.x/itop-incident-mgmt-itil/datamodel.itop-incident-mgmt-itil.xml and put the delta="define" into the details tag without success:

    <details _="define">
        <items>
            <item id="...">
                <rank>...</rank>
             </item>
                 ...
                 ...
            <item id="classification">
                <rank>60</rank>
             </item>
                 ...
                 ...
              <item id="...">
                <rank>...</rank>
             </item>
          </items>
    </details> 
    

    whenever I try to use redifine instead of define I get the following error in the toolkit:

    Error loading module "incident-classification-field": /itop_design/classes/class[cmdbAbstractObject]/class[Ticket]/class[Incident]/fields/presentation/details at line 21: could not be modified (not found) - Loaded modules: ... , itop-incident-mgmt-itil , ...

    even if the incident module is loaded (I set it as dependency)

    Looking at other examples people did not do anything different:
    https://www.itophub.io/wiki/page?id=latest:customization:add-attribute-sample
    https://sourceforge.net/p/itop/discussion/customizing-itop/thread/c9c0597b0d/?limit=25#1c65
    unless I'm missing something

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-05-16

    Plenty of things seem wrong: there's no "ID" attribute for each value (also recommended to only use lowercase and underscore in their names for consistency; they get the translation from the dictionary files anyway).

    Your "presentation" node is contained within fields; also not the proper place.

    And I'm pretty sure it will need to be nested deeper in various "items" nodes or it will pop up in weird places.

     
  • Kai Karger

    Kai Karger - 2022-05-16

    Bless you,

    I'm aware of the translation and nested locations for the item locations but I wanted to simplify it to find the error before going on.

    The error was the closing Fields tag being beneath the Presentation tag. The presentation definition has to come after the fields are closed.

    I must have copied the presentation definition into the wrong line. Maybe I would habe seen it after a night of sleep.

    I will add proper nesting and IDs

     
  • Kai Karger

    Kai Karger - 2022-05-16

    .

     

    Last edit: Kai Karger 2022-05-16

Log in to post a comment.