This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - URGENT, Query for Items using the criteria: Item must not have related items

fli - Thursday, January 19, 2012 6:12 AM:

Hi,

I have an type called A.

A has relationship called B, which relates A to C

 

my question is:

How do I query for all Items of type A which do not have relations to C ?

 

 

/ Christoffer

 



Brian - Sunday, January 29, 2012 6:42 AM:

Hi christoffer,

You could start with something like this:

 

 

 

<AML>
<Item type="A"  action="get" select="item_number,name">
<Relationships>
<Item type="B" action="get" select="id,related_id">
<related_id>
<Item type="C" action="get" select="item_number,name">
<item_number condition="ne">the item number</item_number>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
</AML>

It depends a bit on the number of relationships there are from a source item.

Try that and see if it helps at all.

Cheers,

Brian.



fli - Tuesday, January 31, 2012 6:32 AM:

Brian,

Thanks for your reply,

Itemtype A has multiple Relationships.

 

I don't think querying using the criteria      "related items Property != The Item Number" will work, 

this is because the Items i want returned needs to, Not have related Items.

When querying for "A" Items:  I guess I can't setup logic for a property on Item C if an Instence of Item B doesn't related them.

 

I need a query returning all "A" Items for which there is no Relationship "B".

 

I have noticed that this also i not possible i Std Aras either.

If one sets "Advanced search" choosing Itemtype = "B" ,

          property = related_id  ,  operation = null

 

Can anyone do this query ?

Thanks and BR / Christoffer



vishal_trivedi - Friday, March 9, 2012 7:05 AM:

Hi Christoffer,

Considering that,

1) Source Item type is A.

2) Related Item type is C

3) Relationship Item type is B.

You want to get all the Data of A which are not in relationship with C.

I have tried this thing in context of Part and Document and I can get all the parts which are not connected with Document.

Try below code.

----------

<AML>
    <Item type="A" action="get" where="A.id not in (select source_id from innovator.[B])"></Item>
</AML>

---------

- Vishal



prasad - Monday, March 12, 2012 5:22 AM:

 

Nice work Vishal.

The AML query you invented works perfect. We just have to replace the spaces by "_"(underscore) if present inside the name of Relationship.

For instance, for relationship "Part Document" we need to write "Part_Document".

The AML query is also working without the word "innovator" as below.

-------------

<AML>

     <Item type="A" action="get" where="A.id not in (select source_id from B)"></Item>

</AML>

-------------

Cheers,

Prasad



plm_stud - Wednesday, March 12, 2014 1:43 AM:

Awesome!!!

Thanks, you have made it so simple!! I tried other AMLs and query but they were very complex but this is amazing.

Cheers Vishal!!!!

 



vishal_trivedi - Tuesday, March 13, 2012 12:39 AM:

Thanks Prasad,

Yes you are right. I forgot to mention that "space" will be replaced by "_" (underscore).

Cheers,

Vishal



tin - Friday, March 14, 2014 12:09 AM:

Hi,


I need to get "Part Changes" data for that Particular Part.

For example Part "001"  has undergone changes in which "Changes" tab as that item such as ECN00001 (change no),title.

using AML i need to fetch Part changes data.(chnage no,title) how to do.

I tried below AML query..


<Aml>
<Item type="Part" action="get" id="xxxxxxxxxxxxxxxxxxxx" select="item_number,description,name">
<Relationship>
<Item type="Part Changes" action="get select="item_number,title">
</Item>
</Relationship>
</Item>
</Aml>

Above AML unable to get Part changes data. If you aware kindly help me to get the Part changes data using AML.

Thanks,

 



fli - Thursday, March 15, 2012 8:13 AM:

Cool AML 

thanks,