Hi,
when copying an Item, also the Relationships are duplicated. This is most of the time very useful (e.g. for BOM items), but sometimes I would prefer, if some Relationships wouldn´t be copied (e.g. Costs).
What´s the best way to prevent certain Relationships from being copied? I have found these two options so far, but I am not sure what´s the best approach:
Option 1: Use a custom onCopy Method, that dublicates the Item with the use of theclone method. The method clone contains a parameter that can be used to decide, whether Relationships shall be cloned or not.
But I am not sure, if this parameter applies to all relationships of the source Item.
Option 2: Create an onAfterCopy Method that removes the unwanted Relationships. But this somehow feels like hedge trimming with AML. It produces a nice result, but is pretty rough.
Another option would be, to trigger an additional dialog where users can choose which Relationships to copy. But that's too much work for me right now and I do not need such a luxury solution.
What would you recommend? Or is there some other option available that I haven´t discovered yet?
Thanks for any feedback!
Angela
Hi Angela,
You're correct that using Option 1 will prevent all of the relationships on an item from being copied. Option 2 is also not ideal because it runs two separate server calls: one to run the copy and another one to clean up the relationships. The Save As action that is run to copy an item uses the AML action copyAsNew behind the scenes. To the best of my knowledge, this action doesn't support additional arguments in order to limit which relationships are copied.
I am not aware of any OOTB functionality that supports this exact requirement. The best option to contain all of this logic in one server call would be to create a custom method, but I don't have any sample code to share for coyping an item this.
Chris
Christopher GIllis
Aras Labs Software Engineer
Hi Chris,
Thanks for your feedback! This is not an high-priority issue, but it's always good to know about the possibilities.
I think for the moment I will solve the problem like a real PLM admin: "You released the Part and forgot to check the relationships? You are welcome to start a change process!". Problem solved.
Angela