Menu

ExternalKey filter not applied in remote LinkedSetIndirect attribute

Vasek
2025-01-14
2025-01-14
  • Vasek

    Vasek - 2025-01-14

    Hey. Hey. I have the same problem as was in the thread here:
    https://sourceforge.net/p/itop/discussion/customizing-itop/thread/cf6026f8/?limit=25#b0de

    I have a new class lnkPersonToSoftware where I have an array:

    <field id="software_id" xsi:type="AttributeExternalKey">
    <sql>software_id</sql>
    <target_class>Software</target_class>
    <filter><![CDATA[SELECT Software WHERE type = 'othersoftware' AND status = 'production']]></filter>
    <dependencies>
    <attribute id="org_id"/>
    </dependencies>
    <is_null_allowed>false</is_null_allowed>
    <on_target_delete>DEL_AUTO</on_target_delete>
    </field>
    
    <field id="person_id" xsi:type="AttributeExternalKey">
    <sql>person_id</sql>
    <target_class>Person</target_class>
    <filter><![CDATA[SELECT Person WHERE typecontact = '14193' AND status = 'active']]></filter>
    <dependencies>
    <attribute id="org_id"/>
    </dependencies>
    <is_null_allowed>false</is_null_allowed>
    <on_target_delete>DEL_AUTO</on_target_delete>
    </field>
    

    and then in the Software class:

    <field id="person_list" xsi:type="AttributeLinkedSetIndirect" _delta="define">
    <linked_class>lnkPersonToSoftware</linked_class>
    <ext_key_to_me>software_id</ext_key_to_me>
    <count_min>0</count_min>
    <count_max>0</count_max>
    <ext_key_to_remote>person_id</ext_key_to_remote>
    <duplicates/>
    </field>
    

    and then in the Person class:

    <field id="software_list" xsi:type="AttributeLinkedSetIndirect" _delta="define">
    <linked_class>lnkPersonToSoftware</linked_class>
    <ext_key_to_me>person_id</ext_key_to_me>
    <count_min>0</count_min>
    <count_max>0</count_max>
    <ext_key_to_remote>software_id</ext_key_to_remote>
    <duplicates/>
    </field>
    

    But OQL filter above doesn't work. I've iTOP version 2.7.9.
    Any advice please?
    Thank you.

     
  • Vincent @ Combodo

    Hi Vasek,
    There is no filtering available in XML on "AttributeLinkedSetIndirect" in iTop 2.7
    A <filter> XML tag was brought by 3.1 and is used only in the mode where the AttributeLinkedSetIndirect is displayed as "property"</filter>

    In 2.7, the only way to define a filter on AttributeLinkedSetIndirect, is to create a PrefillSearchForm method.

    In your example, the filter defined on the ExternalKey will be used by iTop 3.1, when adding a relation in pop-up from the Person or the Software in view mode.
    It is also used by iTop 2.7 if you create directly a new lnkPersonToSoftware object, which nearly no-one does.
    Those ExternalKey filters cannot be automatically reversed to build a filter on AttributeLinkedSetIndirect side. We have tried to do it and we end-up to the conclusion, that it is just not logically possible to guess it.

    As a side note your ExternalKey fields dependency on "org_id" does not make sense, as your filter do not take into account the "org_id" field

     
    • Vasek

      Vasek - 2025-01-14

      Thank you Vincent. I will think about the new version of itop.

       

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.