nx_plm - Wednesday, May 30, 2012 9:44 AM:
I have the following IOM code:
Item partItem = inn.newItem("Part", "add");
partItem.setProperty("classification", "Assembly");
Item bomItem1 = inn.newItem("Part BOM", "add");
Item bomItem2 = inn.newItem("Part BOM", "add");
Item relatedItem = inn.newItem("Part", "add");
relatedItem.setProperty("classification", "Assembly");
Item relatedItem1 = inn.newItem("Part", "add");
relatedItem1.setProperty("classification", "Component");
bomItem1.setRelatedItem(relatedItem);
bomItem2.setRelatedItem(relatedItem1);
partItem.addRelationship(bomItem1);
bomItem1.addRelationship(bomItem2);
Item resultItem = partItem.apply();
I get an error which says: "The INSERT statement conflicted with the FOREIGN KEY constraint "FK__PART_BOM__SOURCE__07970BFE". The conflict occurred in database "InnovatorSolutions", table "innovator.PART", column 'ID'. The statement has been terminated. in SQL: INSERT INTO [PART_BOM]"
That ocurrs when I insert the partbom bomItem2 into bomItem1. Originally bomItem2 belongs to partItem and in this case I dont get any error.
Does anyone can know where is the error?
Thank you very much
Brian - Tuesday, June 5, 2012 9:29 AM:
Hi,
I think the line:
bomItem1.addRelationship(bomItem2)
should be:
relatedItem.addRelationship(bomItem2)
You have added the relationship item (Part BOM) to the relationship item (Part BOM) instead of the Part item.
cheers,
Brian.