Can't create BOM with multiple parts through method
- 7 years ago
Hi Rick,
It looks like all you are doing in that loop to parent is add children to it. If that is the case, you might want to create the relationship items directly and not as part of a Relationships node in a parent item:
var bomItem = inn.newItem("Part BOM","add");
bomItem.setProperty("quantity",data[2]);
bomItem.setProperty("sort_order",data[1]);
if (data[3] == "Yes")
{bomItem.setProperty("alt_part",true);}
bomItem.setProperty("source_id", parent.getID());
bomItem.setProperty("related_id", child.getID());
var bomResult = bomItem.apply();This should work pretty straightforwardly, since it is a very simple item creation everytime you loop through, no "setRelatedItem()" or "addRelationship()" stuff.
I know that doesn't address why your code does not work as intended, but for now it's a way you can solve your problem, I believe.Hope this helps.
Cheers,
C