Forum Discussion
Hi Gopikrishnan,
Thanks for the reply. Unfortunately I`m not able to delete the Part BOM relationship item as in your example. I get the nice error "Not a single item" as the error message. Even if i expose the Part BOM itemtype in Innovator TOC and try to delete it form there i get the same message. Its a bit strange since i am an administrator and the item permission states uses the source access that states i should be able to detele the item.
When i manually remove a Part BOM item for a Part i see that the Part BOM relationship exists still on the previsous generation of the part. The Part ItemType is of course under revision control and its possible that in my case blocks me from deleting them.
I have also tried deleting the relationship item from AML studio as the Innovator Admin and its still the same.
Bernt Ove
Hi
Can you check in the Part BOM item type any method is triggered in Server Events tab On After Delete / On Before Delete events ?
- BerntOve5 years agoIdeator III
Hi,
Yes, there is a OnBeforeDelete server event.
- Gopikrishnan5 years agoAccelerator II
Then that method is causing some issue. for time being can you try to remove that event (change from onBeforeDelete to empty) and try running this action
- Gopikrishnan5 years agoAccelerator II
Alternate, if you feel like the onBeforeDelete method is not required to be executed then you can trying updating the part BOM delete method with below line. Add the highlighted line in your method
Innovator inn = this.getInnovator();
Item PartBOM_Relationship = inn.newItem("Part BOM", "get");
Item BOM_Part = inn.newItem("Part", "get");
PartBOM_Relationship.setProperty("source_id", this.getID());
PartBOM_Relationship.setAttribute("select", "id");
BOM_Part.setProperty("ve_classification_display", "PURCHASED PART");
BOM_Part.setAttribute("select", "id");
PartBOM_Relationship.setRelatedItem(BOM_Part);
PartBOM_Relationship = PartBOM_Relationship.apply();
List<String> idLists = new List<String>();
for (int i = 0; i< PartBOM_Relationship.getItemCount(); i++)
{
idLists.Add(PartBOM_Relationship.getItemByIndex(i).getID());
}
if(idLists.Any())
{
Item PartBOM_Delete = inn.newItem("Part BOM", "delete");
PartBOM_Delete.setAttribute("idlist", String.Join(",", idLists));
PartBOM_Delete.setAttribute("serverEvents","0");
PartBOM_Delete = PartBOM_Delete.apply();
if(PartBOM_Delete.isError())
{
return inn.newError("Error Deleting the Part BOM relationship");
}
}
return this;