Search code examples
tridiontridion-2011

Phases in SDL Tridion Event Handler 2011


Have difficulties in understanding Event phases.

1) Consider the Component Save action. When the content is to be overridden based on the content rule, it can be done so in 'Initiated' phase. In case of content disobeying the content rule, errors can be thrown in 'Initiated' or 'Processed' event phases .

When 'Initiated' phase itself is sufficient both for content overriding and content rule validation, When will 'Processed' phase be useful? Pls. explain with an example.

2) While saving and closing the component, 'Save' and 'CheckIn' events are triggered. After the 'Processed' phase of Save action, CheckIn action will take place. In case of any errors during 'Initiated'/'Processed' phase of CheckIn action, 'TransactionAborted' phase of Save action will occur.

Above is the only example that I could think of for 'TrasactionAborted'. Can you provide any other example which will help in understanding 'TrasactionAborted' phase?


Solution

  • Ad1: On the initiated phase the item is not saved yet to the database, and there is no transaction to be rolled back. If you want to validate data you should do this before anything in the database is changed. Of course, transactions are supported and when you raise an exception all will be fine, but you perform unnecessary actions, which all adds up to the performance picture.

    Processed will be useful for situations in which you dont work with the item content itself, but should be able to roll back the change. E.g.: ability to write to an archive or highly business critical event log.

    Another case would be to set a translation required flag on localized children. If that fails you might want to cancel the change on the parent item as well (for some reason).

    Ad2: In general Transaction Aborted would be triggered when any exception occurs. Maybe you can elaborate a bit more on point 2?