How to trigger relationship server event when parent item is copied?

Hi community,

maybe somebody know a solution for this use case. 

I use a Method in the ItemType 'Part BOM' that is triggered by an onAfterAdd and onAfterDelete event. The Method updates an integer property that indicates how often the corresponding child part is used at all. This one is helpful to highlight 'preferred' Parts that are more often used than others.

So each time when an user adds or deletes an Item in a BOM, the counter recalculates how often the child part is used by counting the number of related source parts. 

So far everything works perfect! There is only one usecase that crashes everything. When users copy the parent part (the most used way to add new items...), my calculation Methods in ItemType 'Part BOM' aren´t triggered! The onAfterAdd and onAfterDelete Methods are not called and so my counter property will not be updated. 

I tried all kind of server events available in my child relationship ItemType, but none reacts when copying the parent. 

What options do I have? It might be possible to use an onAfterCopy Method in the Parent ItemType that updates all child parts, but that´s much code for a small requirement. I wonder why my onAfterAdd child event is not triggered, because when I copy something, the child item has to be added.

Or is there some way to explicit trigger the child events with the onAfterCopy parent event?

Any help appriciated!

Thanks!

Angela

  • Hi Angela,

    I can reproduce this error on my local instance of 11.0 SP15. Looking through our internal list of issues, it seems that this is behavior that is seen before and is still being scheduled to be fixed. 

    In the meantime, I think your suggestion of adding an onAfterCopy method to the parent ItemType is the best workaround for now.

    There are a few other alternatives such as making this counter property a federated property and calculating it each time a Part BOM is retrieved from the database. While this would resolve the issue you're seeing, it would also slow down the process of opening and editing parts to the extra time needed for that calculation.

    Chris

    Christopher Gillis

    Aras Labs Software Engineer

  • Hi Chris,

    I really like the idea of using federation for this kind of tasks. Some weeks ago I tried a similar calculation concept for dispaying tab content indicators. But somehow the calculation conflicted with regular database operations.  

    While displaying the federated values worked fine, in my case it was impossible to lock a part. When locking a part, I ran into a timeout error. I assume the combination of 'trigger the calculation' and 'get the item' produced this effect. Or maybe there was a problem with circular references. I just made a quick test of the concept. For the tab indicators the use of real-time calculation was too time consuming. 

    Regarding this topic, thanks for testing this one! I was able to create a more or less simple method that i can use for onAfterCopy and onAfterVerison events. It turned out, that versioning an item also doesn´t update the BOM counter.
    Even copying larger now BOMs works well, so I am happy with the current workaround.