I'm trying to send an email on promotion to "Released" of Parts when a couple of criteria are met, the parts being of a certain custom classification we've added, and them not being used in another BOM anywhere (i.e. they're top-level Parts being released).
What's the best way to go about checking whether the part is a top-level part (i.e. doesn't have a parent)? I've tried isRoot(), getParentItem(), and getProperty("source_id"), but I'm either misusing those or for some reason they're not working for my case.
This is what I have tried so far (this method is attached as a Post method to the lifecycle transitions to Released, and it is generating the emails, it's just not limiting it to only the times when it's a top-level BOM, like I want):
Innovator inn = this.getInnovator(); Item myResult; if (this.getProperty("classification", "") == "Hull Assembly" && this.isRoot() == true) { //email code } return this; //or Innovator inn = this.getInnovator(); Item myResult; if (this.getProperty("classification", "") == "Hull Assembly" && this.getParentItem() == null) { //email code } return this; //or Innovator inn = this.getInnovator(); Item myResult; if (this.getProperty("classification", "") == "Hull Assembly" && this.getProperty("source_id", "") == "") { //email code } return this;