I'm working with Web 8 and Web 8.5, in both I need to be able to stop a publish based on a custom logic (I should not allow it to be made), my options are:

  1. Use event system Probably something like:

    EventSystem.SubscribeAsync<Page, PublishEventArgs>(OnPagePublishPre, EventPhases.Initiated);
  2. Use Custom Resolver

It's my understanding I can accomplish the stop with both approaches. My question is if there's one that's better over the other, taking into account performance and cases where many pages/components can be sent to be published.

I don't find the life cycle of this, which one would happen first?

Thanks in advance! Guillermo.

  • Based on what do you want to “stop”publishing? Do you want to show a message/error to the user in case you decide to “stop”? Do you expect Publish Transactions to be created in that case? Jul 13, 2018 at 20:35
  • My requirement would be the transaction either be stopped or not created at all (better). Then secondary, send a message to the user.
    – polonskyg
    Jul 13, 2018 at 20:54
  • Authorization, workflow, and changing the content model (e.g. Component without a Component Template) are other ways to control when something is published. If possible, it could be easier on editors if they can't even access or publish certain items rather than having an action stopped.
    – Alvin Reyes
    Jul 14, 2018 at 16:29

1 Answer 1


Like Rick asked in the comment, it depends on what you want to achieve...

If you use a Custom Resolver, you will always end up with Publish Transactions, even if you remove all the items from the resolved items list. Such Transactions will have a Warning state (that lets you know that something is fishy about them).

On the other hand if you use an Event System, you can stop the Transaction from being saved in the first place. But as far as I know, there is no other way to stop an action from within the event system apart from throwing an exception. Throwing one will result in stopping the action and the exception message showing up in Tridion's message center.

One last thing, for events handlers which need to do something with the "Subject" of the event, you should use (synchronous) Subscribe, and not SubscribeAsync. Async event handlers are exectued at one point, there is no guarantee when, and your handler code can end up executing "to late". In your example code you have async.


As far as I know, yes. You could try and check:

  • The Publish Transaction's State in your event handler, In Progress being the first one
  • plus whether the transaction matches your condition

and if both are true, then delete it. But, I haven't tested this.

That reason for checking the State of transaction is because a Save event is triggered many times for a single transaction. To be more precise, for every change that is happening inside it (State change, some other properties (ResovledItems, ProcessedItems, etc.) being set, etc.

Throwing an exception will show the message without any additional code needed.

  • My requirement would be the transaction either be stopped or not created at all (better). Then secondary, send a message to the user. So the only option to stop it is throwing an exception?
    – polonskyg
    Jul 13, 2018 at 20:55
  • See my updated answer
    – Atila Sos
    Jul 13, 2018 at 21:07
  • Interesting, I'll give it a try, if it works, I'll accept your answer. Thx!
    – polonskyg
    Jul 16, 2018 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.