I've created a custom extension named "Supplier" in iTop to manage suppliers details who provides the organizations with hardware/software or services.
Extension is working fine except for:
In the UI I have a field called as Asset Owner as a Drop Down which lists the Teams in the organizations, Basically Teams are point of contact in the organization to talk to the respective supplier.
Teams are not populated according to the "org_id" I select in the organization drop down. It simply lists all the available teams in all organizations.
Here is the code which I wrote to filter the Teams based on the org_id
Applied dynamic filter settings within the "Supplier" extension.
<field id="asset_owner" xsi:type="AttributeExternalKey">
<target_class>Team</target_class>
<is_null_allowed>false</is_null_allowed>
<sql>asset_owner_id</sql>
<is_dynamic>true</is_dynamic>
<depends_on>org_id</depends_on>
<enabled_if><![CDATA[this.org_id != 0]]></enabled_if>
<dynamic_filter><![CDATA[SELECT t FROM Team AS t WHERE t.org_id = :this->org_id]]></dynamic_filter>
</field>
Situation forced me to be iTop developer, any help or suggestions would be greatly appreciated!
How did you come up with the "enabled_if", "is_dynamic" and "dynamic_filter"? Unless you're using a custom extension - I've never seen those attributes.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I copied the Monitor class and made some changes to create the Supplier class.
The enabled_if, is_dynamic, and dynamic_filter attributes were suggested by ChatGPT when I was looking for a way to dynamically filter the Teams based on the org_id.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Team,
I've created a custom extension named "Supplier" in iTop to manage suppliers details who provides the organizations with hardware/software or services.
Extension is working fine except for:
In the UI I have a field called as Asset Owner as a Drop Down which lists the Teams in the organizations, Basically Teams are point of contact in the organization to talk to the respective supplier.
Teams are not populated according to the "org_id" I select in the organization drop down. It simply lists all the available teams in all organizations.
Here is the code which I wrote to filter the Teams based on the org_id
Applied dynamic filter settings within the "Supplier" extension.
<field id="asset_owner" xsi:type="AttributeExternalKey">
<target_class>Team</target_class>
<is_null_allowed>false</is_null_allowed>
<sql>asset_owner_id</sql>
<is_dynamic>true</is_dynamic>
<depends_on>org_id</depends_on>
<enabled_if><![CDATA[this.org_id != 0]]></enabled_if>
<dynamic_filter><![CDATA[SELECT t FROM Team AS t WHERE t.org_id = :this->org_id]]></dynamic_filter>
</field>
Situation forced me to be iTop developer, any help or suggestions would be greatly appreciated!
Please find the attached for reference..!
How did you come up with the "enabled_if", "is_dynamic" and "dynamic_filter"? Unless you're using a custom extension - I've never seen those attributes.
I copied the Monitor class and made some changes to create the Supplier class.
The enabled_if, is_dynamic, and dynamic_filter attributes were suggested by ChatGPT when I was looking for a way to dynamically filter the Teams based on the org_id.
I'm afraid ChatGPT doesn't know iTop well enough yet ;)
https://www.itophub.io/wiki/page?id=3_2_0:customization:xml_reference