Forum Discussion

Former_Member's avatar
Former_Member
Accelerator III
9 years ago

How to clear relationship on new Revision?

I have an ItemType A with a RelationShip to another ItemType B. I want all relations to stay within a Revision. But when a new Revision is created for ItemType A I do not want the old relations to be carried over to the new Revision. Is there any "build in" feature in  Aras to handle this or must i do it with code? My idea was to clear the relations on a server event, but I can not find any event "onRevision". I can only find onVersion but that is not called when I go to a new Revision. Any suggestions?

4 Replies

  • There is no onRevision event that I'm aware of. By onVersion, I am assuming that you mean onBeforeVersion or onAfterVersion. If so, are you hooking the before or after event? I think you'll want to hook the after. Be aware that the Version events are fired whenever a new generation is created. Therefore, if you have an item A with item B relations, item A is generation 1 in the preliminary state, and you lock item A to make a change creating generation 2, then the version events will fire when you save item A. It's unlikely that this is the functionality you desire. If you are using the out of the box change processes, then one option is to make a modification to the PE_ChangeItemTransition method to delete the relationships from the new revisions when that method makes the new revisions of the affected items. Dennis
  • That's corrrect, I tried the onAfterVersion method but that method is not called when a new Revision is created, or rather that method is called when the last generation of the previous Revision is saved, so I can not delete the relationships on the next Revision using that method. Modifying PE_ChangeItemTransition seems like a "dirty"  solution for this problem, but if that is the only solution I can try that out. You do not have any other suggestions? Is there any server event method that is called when a new revision is created? If there is, I could easily check if Generation is equals to "A" and then remove the relationships.
  • In my 11sp6 out of the box environment, the onAfterVersion event is fired when revision B is made from an ECO. The context item of the onAfterVersion event is the old generation (rev A), but your method can retrieve the latest generation based on config_id. This is the approach that PE_AffectedItemFloat uses (also hooked to onAfterVersion). Once you have the new generation, then you can delete the relationships. As you said, your method will need compare major_revs between generations to determine if it should delete the relationships. Dennis  
  • Great! I was afraid that the new Revision had not been created yet when the onAfterVersion was called. This is exactly what I want, I just compare that the oldVer.Major_rev != newVer.Major_rev are then removes the relations. Thanks!