Menu

Dymanic filter not working to filter Teams as per Org_id

Sunilkumar
2024-07-01
2024-07-02
  • Sunilkumar

    Sunilkumar - 2024-07-01

    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..!

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2024-07-01

    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.

     
  • Sunilkumar

    Sunilkumar - 2024-07-02

    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.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.