How to get part numbers from part IDs
I have a query that returned a large number of part IDs that have a single eBOM item ID.
To get the part IDs converted to part numbers I used the AML "idlist" function.
How can I get the part BOM IDs converted to part numbers and keep the relationship with the part number they belong to?
Note: My IDs are a long string separated by commas.
Don
If I'm understanding you correctly here, you're looking for the part numbers of all the child parts for BOM relationships with exactly 1 child.
If you don't care about the IDs, we should be able to modify the above script very slightly to get you what you need.[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:bdddaaf2-822e-42f9-88df-16bac7f4c1d8:type=csharp&text=var%20inn%20%3D%20this.getInnovator%28%29%3B%0D%0A%0D%0Avar%20parts%20%3D%20inn.newItem%28%22Part%22%2C%22get%22%29%3B%0D%0Aparts%20%3D%20parts.apply%28%29%3B%0D%0AList%3Cstring%3E%20relPartList%20%3D%20new%20List%3Cstring%3E%28%29%3B%0D%0AList%3Cstring%3E%20sourcePartList%20%3D%20new%20List%3Cstring%3E%28%29%3B%0D%0Afor%20%28int%20i%20%3D%200%3B%20i%20%3C%20parts.getItemCount%28%29%3B%20i%2B%2B%29%7B%0D%0A%20%20var%20currPart%20%3D%20parts.getItemByIndex%28i%29%3B%0D%0A%20%20var%20bomRel%20%3D%20inn.newItem%28%22Part%20BOM%22%2C%22get%22%29%3B%0D%0A%20%20bomRel.setProperty%28%22source_id%22%2CcurrPart.getID%28%29%29%3B%0D%0A%20%20bomRel%20%3D%20bomRel.apply%28%29%3B%0D%0A%20%20%2F%2Fthis%20is%20each%20relationship%20with%201%20child%20part%0D%0A%20%20if%20%28bomRel.getItemCount%28%29%20%3D%3D%201%29%7B%0D%0A%20%20%20%20%2F%2Fthis%20related_id%20is%20the%20child%20Part%2C%20bomRel.getID%28%29%20would%20actually%20get%20us%20the%20ID%20of%20the%20BOM%20Relationship.%0D%0A%20%20%20%20%2F%2FrelPartList.Add%28bomRel.getProperty%28%22related_id%22%29%29%3B%0D%0A%20%20%20%20%2F%2FWhat%20we%20want%20is%20to%20get%20the%20actualy%20child%20part%20which%20is%20the%20related_id%20of%20the%20BOM%20relationship%0D%0A%20%20%20%20var%20relPart%20%3D%20inn.getItemById%28%22Part%22%2CbomRel.getProperty%28%22related_id%22%29%29%3B%0D%0A%20%20%20%20%2F%2Fnow%20that%20we%20have%20access%20to%20the%20related%20part%2C%20we%20can%20simply%20query%20the%20part%20number%0D%0A%20%20%20%20var%20itemNumber%20%3D%20relPart.getProperty%28%22item_number%22%2C%22%22%29%3B%0D%0A%20%20%20%20sourcePartList.Add%28%24%22Part%20Num%3A%20%7BcurrPart.getProperty%28%22item_number%22%2C%22%22%29%7D%2C%20Related%20Part%20Num%3A%20%7BitemNumber%7D%22%29%3B%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0Areturn%20inn.newResult%28%22Parts%20with%201%20Item%20in%20EBOM%3A%5Cn%22%20%2B%20String.Join%28%22%5Cn%22%2CsourcePartList%29%29%3B]
This returned the following output in my test system (only one instance of this occurring):
<Result>Parts with 1 Item in EBOM: Part Num: test, Related Part Num: BC-BELL</Result>
Now with over 9000 parts this method might not run too quickly, but it should get you the answer you're looking for. If this is something you're going to run routinely let me know and I can see if there's a better way to run this query more efficiently.