Phases in the SDL Tridion 2011 event handler

Difficulties in understanding the phases of events.

1) Consider the action "Save component". When content needs to be redefined based on the content rule, this can be done in the Initiated step. In case the content does not obey the content rule, errors can be sent at the “Initiated” or “Processed” stages.

When the Initiated phase itself is sufficient both to redefine the content and to verify the correctness of the content, when will the Processed phase be used? Pls. explain with an example.

2) When a component is saved and closed, the "Save" and "Check" events are triggered. After the "Processed" step of the "Save" action, the CheckIn action will be performed. In case of any errors during the Initiated / Processed phase in the CheckIn action, the TransactionAborted Save action action will occur.

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

+6
source share
2 answers

Ad1: At the started phase, the item has not yet been saved to the database, and the transaction will not be canceled. If you want to validate the data, you must do this before anything in the database is modified. Of course, transactions are supported, and when you throw an exception, everything will be fine, but you perform unnecessary actions that all add to the performance image.

Processed will be useful for situations in which you do not work with the contents of the element itself, but should be able to roll back the change. For example: the ability to write to an archive or a critical event log.

Another case would be to set the translation flag for localized children. If this fails, you can also undo the change in the parent element (for some reason).

Ad2: In general, Transaction Aborted will fire when any exception is thrown. Maybe you can tell more about the 2nd point?

+6
source

I tried to give a complete explanation of the phases of events, event types, and object types of SDL Tridion 2011 in the following article on SDL Tridion World: SDL Events Tridion 2011.NET .

In short, the phases start in a specific order, so you can connect to the action at a specific time, the order is as follows:

  • Initiated phase
  • CMS action in progress (not phase)
  • Processed phase
  • One of the phases of the transaction (TransactionCommitted, if the transaction was successful, TransactionAborted in case of interruption of the transaction and TransactionInDoubt, when the state of the transaction cannot be determined, it is not canceled and is not interrupted and will never be)

So, if you want to do something before the item is saved (for example, check the validity of the item, in which case you can prevent it from being saved, you can best use the Initiated step, but if you want to do something after the item has been saved (for example, by placing it on the page), you should use the Transaction Committed phase (in this case, at least one of the Check-in, not the Save event, is possible).

So, when the phase being handled comes to usefulness, I can never come up with a simple use case, but I’m sure that in some situations it will come in handy at some point. The fact that it exists does not mean that you need to use it immediately.

+6
source

Source: https://habr.com/ru/post/920565/


All Articles