Forum Discussion
Hi Maddy,
Gopikrishnan is correct that this sort of grouping isn't available OOTB. In order to get this exact functionality, you would need to write some custom logic. However, I want to propose an alternative query that is possible through AML alone.
Using the standard Part item as an example, the major_rev is typically incremented when a Released Part is modified. Following this logic, the item with the greatest generation per major_rev will be in the Released state. By querying on either the state or the is_released property, we can effectively accomplish the query you're looking for.
<AML>
<Item type="Part" action="get" select="item_number, generation, major_rev">
<is_released>1</is_released>
<!-- By default, non-current items aren't returned by an AML query. We can get them to appear by including generation in the criteria like this -->
<generation condition="gt">0</generation>
</Item>
</AML>
What you might notice from the query above is that it may not return the most recent Part if that part isn't also in the Released state. We can account for this by chaining another query immediately after this one like so:
This chained query should return all of the items you're expecting. This exact approach assumes that you're using the Part ItemType; however, you can use a similar approach as long as your versioning logic includes some condition for when a new major_rev is created. For example, you may need to use something like <state>Released State</state> instead of <is_released>1</is_released> if you're using a custom ItemType that doesn't have the is_relased property.
Chris
Christopher Gillis
Aras Labs Software Engineer
Thanks Christopher. This looks to be a simple. However if the latest generation is released, then the combined query will fail as latest revision is_released = '1'. so, second query might return no records.
<AML>
<Item type="Part" action="get" select="item_number,generation,major_rev">
<item_number>TESTPART1</item_number>
<generation condition="gt">1</generation>
<is_released>1</is_released>
</Item>
<Item type="Part" action="get" select="item_number,generation,major_rev">
<item_number>TESTPART1</item_number>
<is_released>0</is_released>
</Item>
</AML>