Hi,
I`m currently trying to develop a function that easily deletes all Part BOM lines of a specific type (in our configuration "Purchased Parts"). All assebly parts should be left alone since in my next part of development my plan is to run the method also on these (i.e. make it recursive).
I have made an action on the Part Item that runs the following code:
Innovator inn = this.getInnovator();
Item qryItm = inn.newItem("Part", "get");
Item PartBOM_Relationship = inn.newItem("Part BOM", "get");
Item BOM_Part = inn.newItem("Part", "get");
qryItm.setID(this.getID());
PartBOM_Relationship.setRelatedItem(BOM_Part);
qryItm.addRelationship(PartBOM_Relationship);
Item partItm = qryItm.apply();
partItm.setAction("edit");
Item partRelationships = partItm.getRelationships("Part BOM");
for (int i=0; i< partRelationships.getItemCount(); i++) {
Item part_relationship = partRelationships.getItemByIndex(i);
Item partItem = part_relationship.getRelatedItem();
if (partItem.getProperty("ve_classification_display", "") == "PURCHASED PART") {
partItm.removeRelationship(part_relationship);
}
}
partItm = partItm.apply();
return partItm;
I have checked that the if is triggered and a new generation of the part is generated, but the Part BOM relationships are still there in the new generation of the part.
I have also tried to delete the relationship item but this is not allowed in my current configuration.
What am i missing?