I am customizing iTop by creating an extension. Everything was going fine until I tried to
extend the Farm object and use field of an AttributeExternalKey and AttributeExternalField
pair. My XML definition is:�
<classid="Farm"_delta="if_exists"><fields><fieldid="location_id"xsi:type="AttributeExternalKey"><sql>location_id</sql><filter><![CDATA[SELECT l FROM Location AS l JOIN Organization AS root ON l.org_id=root.id JOIN Organization AS child ON child.parent_id BELOW root.id WHERE child.id= :this->org_id]]></filter><dependencies><attributeid="org_id"/></dependencies><target_class>Location</target_class><is_null_allowed>true</is_null_allowed><on_target_delete>DEL_MANUAL</on_target_delete><allow_target_creation>true</allow_target_creation></field><fieldid="location_name"xsi:type="AttributeExternalField"><extkey_attcode>location_id</extkey_attcode><target_attcode>name</target_attcode></field></fields><presentation>.
.
.
</presentation></class>
But Data Model Toolkit is complaining about missing <sql> tag, which is for sure presented.
DMT error:</sql>
This is most likely because you didn't put a "_delta" attribute on the "field" tag. Therefore the compiler is only keeping the structural nodes but not their content. Just add "_delta="define"" on that node and it should work alright.
Hope this helps,
Guillaume
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i just tested this
<field id="user-content-location_id" xsi:type="AttributeExternalKey" _delta="define"> as mention by Guillaume
In fact if you don't have _delta="define" instruction before the field section, you have to use it for each new attribute you define
So it is the same for location_name</field>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One more problem on it, now as I moved forward and finetuned the presentation section. The result is duplicating displayed Farm properties/fields which is not happening with other extended entities like Server or VirtualMachine and NetworkDevice.
complete XML definition:
<classid="Farm"_delta="if_exists"><fields><fieldid="location_id"xsi:type="AttributeExternalKey"_delta="define"><sql>location_id</sql><filter><![CDATA[SELECT l FROM Location AS l JOIN Organization AS root ON l.org_id=root.id JOIN Organization AS child ON child.parent_id BELOW root.id WHERE child.id= :this->org_id]]></filter><dependencies><attributeid="org_id"/></dependencies><target_class>Location</target_class><is_null_allowed>true</is_null_allowed><on_target_delete>DEL_MANUAL</on_target_delete><allow_target_creation>true</allow_target_creation></field><fieldid="location_name"xsi:type="AttributeExternalField"_delta="define"><extkey_attcode>location_id</extkey_attcode><target_attcode>name</target_attcode></field></fields><presentation><details><items><itemid="contacts_list"><rank>10</rank></item><itemid="documents_list"><rank>20</rank></item><itemid="applicationsolution_list"><rank>30</rank></item><itemid="logicalvolumes_list"><rank>40</rank></item><itemid="hypervisor_list"><rank>50</rank></item><itemid="virtualmachine_list"><rank>60</rank></item><itemid="providercontracts_list"><rank>70</rank></item><itemid="services_list"><rank>80</rank></item><itemid="col:col1"><rank>90</rank><items><itemid="fieldset:Server:baseinfo"><rank>10</rank><items><itemid="name"><rank>10</rank></item><itemid="org_id"><rank>20</rank></item><itemid="location_id"><rank>30</rank></item><itemid="status"><rank>40</rank></item><itemid="business_criticity"><rank>50</rank></item><itemid="move2production"><rank>60</rank></item><itemid="description"><rank>70</rank></item></items></item></items></item></items></details><search><items><itemid="name"><rank>10</rank></item><itemid="org_id"><rank>20</rank></item><itemid="location_id"><rank>25</rank></item><itemid="business_criticity"><rank>30</rank></item><itemid="move2production"><rank>40</rank></item></items></search><list><items><itemid="org_id"><rank>10</rank></item><itemid="location_id"><rank>15</rank></item><itemid="status"><rank>20</rank></item><itemid="business_criticity"><rank>30</rank></item><itemid="move2production"><rank>40</rank></item></items></list></presentation></class>
Like for the field, you have to put the right _delta flag on the nodes you want to add/remove/modify. You should take a look at the documentation here.
Cheers,
Guillaume
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am customizing iTop by creating an extension. Everything was going fine until I tried to
extend the Farm object and use field of an AttributeExternalKey and AttributeExternalField
pair. My XML definition is:�
But Data Model Toolkit is complaining about missing <sql> tag, which is for sure presented.
DMT error:</sql>
Suppport info:
Last edit: Martin Vysohlid 2021-05-26
Hello Martin,
This is most likely because you didn't put a "_delta" attribute on the "field" tag. Therefore the compiler is only keeping the structural nodes but not their content. Just add "_delta="define"" on that node and it should work alright.
Hope this helps,
Guillaume
i just tested this
<field id="user-content-location_id" xsi:type="AttributeExternalKey" _delta="define"> as mention by Guillaume
In fact if you don't have _delta="define" instruction before the field section, you have to use it for each new attribute you define
So it is the same for location_name</field>
Thank you both, it was just that problem. I was copy/pasting attributes from original definition XML and doesn't added the _delta property.
Last edit: Martin Vysohlid 2021-05-26
One more problem on it, now as I moved forward and finetuned the presentation section. The result is duplicating displayed Farm properties/fields which is not happening with other extended entities like Server or VirtualMachine and NetworkDevice.
complete XML definition:
Last edit: Martin Vysohlid 2021-05-26
Like for the field, you have to put the right _delta flag on the nodes you want to add/remove/modify. You should take a look at the documentation here.
Cheers,
Guillaume
Just to add a reference to the original ticket : [#1977]
Related
Tickets:
#1977OK finaly got the point, thank you werry much, this also simplified the extension's XML definition.
Glad to see you fixed it! 😊
Take care Martin,
Guillaume