rif6894 - Saturday, March 3, 2012 1:39 AM:
I wish to write a server side, C# method, that is to update an attribute on a relationship. The scenario is a heirarchy of parts:
Part 100 --> Part BOM Relationship --> Part 001
Part 100 --> Part BOM Relationship --> Part 002
I wish to:
- For each of the Part BOM Relationships coming from Part 100
Get the State (Preliminary, In Review, Released...) for each of the related Parts (001 and 002)
Update the Relationship attribute, say,'Reference Designator', to the State of the child object.
This method will be created as an 'Item Type' method, that is manually initiated.
I have reviewed the Program Guide, but I cannot locate an example that is similar to the above scenario.
Any code suggestions would be apprieciated.
Thanks in advance
Eric Domke - Thursday, March 8, 2012 8:47 PM:
I haven't tried it out, but something along the following lines should get you started:
var inn = this.getInnovator(); var part = inn.newItem("Part", "get"); part.setProperty("item_number", "Part 100"); var bomItems = inn.newItem("Part BOM", "get"); bomItems.setAttribute("select", "related_id(state)"); bomItems.setPropertyItem("source_id", part); bomItems = bomItems.apply(); if (bomItems.isError()) return bomItems; Item bomItem; Item childPart; Item newBomItem; for (int i = 0; i < bomItems.getItemCount(); i++) { bomItem = bomItems.getItemByIndex(i); childPart = bomItem.getPropertyItem("related_id"); newBomItem = inn.newItem("Part BOM", "edit"); newBomItem.setID(bomItem.getID()); newBomItem.setProperty("reference_designator", childPart.getProperty("state")); newBomItem = newBomItem.apply(); if (newBomItem.isError()) return newBomItem; } return part;