Carlo Clausius - Wednesday, November 5, 2008 6:39 PM:
Hi
I'd like to add existing parts to an existing part BOM. All the examples that I've seem relates to adding new parents and children.
I.e. This is a typical example that I've read.
<AML>
<Item type="Part" action="add">
<item_number>801-0150-70-01</item_number>
<Relationships>
<Item type="Part BOM" action="add">
<quantity>1</quantity>
<related_id>
<Item type="Part" action="add">
<item_number>446-0445-01-01</item_number>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
</AML>
But this returns an error as the parent already exists (as does the child).
Thanks
Carlo
Sean - Thursday, November 6, 2008 4:01 PM:
Carlo
You do have the correct idea with what you want to do but you just need to change the actions attributed to each <Item> tag. To be able to Add an existing Part to a Part BOM relationship for a part that exists as well just look at the actions I have edited and highlighted.
<AML>
<Item type="Part" action="edit">
<item_number>801-0150-70-01</item_number>
<Relationships>
<Item type="Part BOM" action="add">
<quantity>1</quantity>
<related_id>
<Item type="Part" action="get">
<item_number>446-0445-01-01</item_number>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
</AML>
The reason for the error is due to the fact when you use action="add" you are attempting to create a new item, in this case a new part. In the case of part the property item_number is unique so it is erroring due to the fact you are trying to add a part with an item_number that already exists.
Hope this helps.
Sean
RobMcAveney - Friday, November 7, 2008 10:51 AM:
Just to clarify a bit, when using action="edit" you need to specify exactly which item you are editing. The most common way to do this is by setting the id attribute, like this:
<Item type="Part" action="edit" id="8AD6FC0422494CD3BF5D5CD4204E7F74" >
If you don't have the id of the item, the next best way to do it is with the where attribute, like this:
<Item type="Part" action="edit" where="[PART].item_number='801-0150-70-01' and [PART].is_current='1'" >
The "is_current" condition just makes sure you are editing the latest version of the Part.
Rob