This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Lifecycle or state change event

zapping - Thursday, March 31, 2011 2:39 PM:

Hi,
  Is there a server-side event that is called when state of a part is changed, as I need to call a 3rd party service when a part gets superceded.

Thanks,
Zaps.



Brian - Sunday, April 3, 2011 12:27 AM:

Hi Zaps,

In the Part Lifecycle click on the transition that leads to the state you are interested in (Superseded).

There is an option on the Transition to run server methods Pre and Post transition. Write the Server Method to call your third party service and run it Post transition. This way you can be sure that the Part is already in the state you are looking for since this method will be run after the transition has occurred..

Hope this helps.

Brian.



zapping - Friday, April 8, 2011 4:54 AM:

Hi Brian,
  Thank you for the tips. It works but one more tip please. Is there a way to abort from the post event. Am trying to connect to an Oracle db and pass on the status to a 3rd party system that needs to be in sync with the part status/state. If at all an error occurs during the call to 3rd party can the state change be rolled back. Tried doing a return this.getInnovator.newError("message") but it does not rollback.

thanks,
zaps.



Brian - Friday, April 8, 2011 6:43 AM:

Hi Zap,

I think in this situation I would first of all call the Promotion from a method. That way I can respond to the Promotion succeeding or failing.

The order that you update the systems depends on which system is easier to roll back. If the 3rd party system can be easily rolled back then I would call the 3rd party app in the Pre-tranistion event. If it fails at this point then you just return false from the method. This will cancel the transition and the systems will be in sync.

Assuming the transition works properly then your systems are in sync.

If the Innovator tranistion fails then you can roll the 3rd party app back to the pre-transition state because you have captured the result of the Promotion in the method that called it in the first place.

If Innovator is easier to roll back than the 3rd party system then you need to have a path back from the final promotion state in case the 3rd party app fails in its update. Then you call call for the 3rd party app from the Post Transition event. If this call fails then you promote Innovator back to the state it was in before the original call. Since a promotion doesn't otherwise affect the properties of the Innovator item except for the state then you should be OK after the promotion back to the prior state.

Hope this helps,

Cheers,

Brian.