Forum Discussion
I think it´s possible to delete all elements of type 'Part_BOM' which has the source_id of your parent Part.
<Item type="Part_BOM" action="delete" where="[Part_BOM].source_id='123456....'"></Item>
Not tested! Use with care :-).
- Former_Member7 years agoIdeator I
Thanks! I will give that a try now and see what I get. Cheers!
- Former_Member7 years agoIdeator I
I think I am close, I have the following:
<Item type="Part BOM" action="delete" where="Part_BOM.source_id='@1'"></Item>
The parent part number I am reading from a file, first column. I am not getting errors during execution, but the part BOM is still there (the command did not delete the BOM, I can still see it in the part). I think this line makes perfect sense so I will look into it again and see if I missed anything. I also tried the following script:
<!-- To delete a complete BOM, round 2, no errors but not working -->
<Item type="Part" where = "item_number = '@1' and is_current = '1' " action="edit">
<Relationships>
<Item type = "Part BOM" action = "delete" where="Part_BOM.source_id='@1'"></Item>
</Relationships>
</Item>Should I change my approach, or am I on the right track?
- Gopikrishnan7 years agoIdeator I
Hi Pmateo
It should be on opposite way. You need to use the related_id. (Source ID is ID of Parent Part and Related ID is ID of Child Part)
Example:
Parent1 --> Child1
Parent2 --> Child1
If you want to delete Child1 in Parent1 and Parent2. Use below query
<AML>
<Item action='delete' type='Part BOM' where="[Part_BOM].related_id='773D6786B7DE48439F373F59'"></Item>
</AML>Here Related ID is ID of the Child1.
Hope it helps.
Thank You
Gopikrishnan
- Former_Member7 years agoIdeator I
Hi. Thanks a lot for the suggestion. Even when I run the query as you specified I don't get any errors, but the BOM stays in place. I am starting to believe something is preventing me from deleting BOM using queries (manually I can).
If I understand correctly, the query you sent would delete Child1 everywhere right? If it belongs to 10 parents, then all 10 parts will have Child1 deleted. I was trying to go the other way around, I want to delete all child parts from a given parent, regardless of how many there are in one go; that's where I got the query <Item type="Part BOM" action="delete" where="Part_BOM.source_id='@1'"></Item> but exactly as when I ran yours: no errors show up but the BOM doesn't change. I will re-read the documentation in the developers forum and give it another try.