Forum Discussion
Hello!
If you need to find parent items, you have a couple of approaches depending on whether you are looking up a single item or multiple items. Here is a clearer breakdown of how to handle this:
Method 1: Using the getItemWhereUsed Action
You can retrieve all the parents of an item using the getItemWhereUsed AML action. The primary limitation of this method is that it requires a specific id attribute, meaning you can only retrieve the parents for one item at a time.
<AML>
<Item type="ItemTypeB" action="getItemWhereUsed" id="value"/>
</AML>Method 2: Using an SQL Subquery (For Multiple Items)
If you need to query multiple items at once, you can use an SQL subquery within the where attribute. However, for this to work, you must explicitly suppress the standard Item Analysis for these types of queries.
Here are the steps to generate that suppression:
1. Create a Suppressions File: Navigate to your \Innovator\Server\App_Data folder and create a new XML file following the naming convention ItemAnalysis.Suppressions.*.xml.
Example: \Innovator\Server\App_Data\ItemAnalysis.Suppressions.MyCustom.xml
2. Define the Template: Open the file and add the following XML format to define your suppression template:
<itemAnalysis>
<suppressions>
<whereAttribute>
<template><![CDATA[ItemTypeB.id IN (SELECT related_id FROM RelationshipType WHERE source_id IN (SELECT id FROM ItemTypeA WHERE some_property LIKE @Parameter))]]></template>
</whereAttribute>
</suppressions>
</itemAnalysis>3. Restart IIS and Execute: Save the file, restart your IIS server to apply the changes, and then execute your AML query.
<AML>
<Item type="ItemTypeB" action="get" where="ItemTypeB.id IN (SELECT related_id FROM RelationshipType WHERE source_id IN (SELECT id FROM ItemTypeA WHERE some_property LIKE 'value%'))"> </Item>
</AML>