2

We have a requirement where we need to disable creating transactions in some Publications. We cannot remove these publications from Publication Target, because we need them, but we would like to do it via the Event System for example on transaction save args.

I have tried in EventPhase.Initiated, but nothing seems to work.

Has anyone had similar requirement and how did they achieve it?

UPDATE:

OK, so here is my thing, to make it plastic.

We have Publications:

  • level 1
  • level 2
  • level 3
  • level 4

I want to be able to publish from each of these levels, but, if I send item to publish from level 1 in all child Publications (2, 3, 4), I want to have only transactions from level 1 and 4. I also don't want to remove level 2 and 3 from Publication Target, because then I will not be able to publish from that level in all children (level 4), which is a must.

  • Do you mean you want to disable Publish Transactions to be created, as in disable the ability to Publish a Page or a Component? That is normally something you should do through the Publish rights I would say. But maybe you can edit your question and provide a bit more details about who/what is and isn;t allowed to do something, because only then you can try to automate it. – Bart Koopman Oct 3 '17 at 16:14
  • 1
    What do you mean by "creating transactions?" Do you mean publishing and saving items, or something entirely different? And what exactly did you try that doesn't work? If you throw an exception during an event it will prevent its completion (unless in Commited phase). – Nickoli Roussakov Oct 3 '17 at 16:15
  • everyone should be able to publish in all child publications, i need publish enabled in all publications, i just don't want some publications to clog publish queue.honestly, to me this screams custom resolver, but i am interested if this can be achieved via event system. So, when i send item to publish from lvl 1 in all child publications, my publish queue should have just transactions from lvl 1 and 4. – Marko Milic Oct 3 '17 at 20:01
  • 1
    I would maybe rephrase my colleague Marko's question to: Is it possible to cancel an ongoing action using Tridion Event System (besides throwing an exception)? – Atila Sos Oct 4 '17 at 11:47
  • @AtilaSos see my updated answer – Bart Koopman Oct 5 '17 at 16:34
4

I'm mainly responding to your comment on @Harald's answer, and the removal of these empty Publish Transactions.

What I find interesting in your question is that you seem to want to find a way to remove certain items from your publish action, but I didn't actually understand if you have a clear algorithm for that. Because without that I would say it is impossible to automate.

But on the actual task of the removal of empty Publish Transactions, I can suggest the following example code:

  1. https://appstore.sdl.com/web-content-management/app/child-publications-only-resolver/621/
  2. https://appstore.sdl.com/web-content-management/app/empty-publish-transactions-event-handler/622/

To answer @Atila's question in the comments, no it is not possible to cancel an ongoing action using Tridion Event System besides throwing an exception. You can only stop it by throwing an exception, that is the mechanism that is designed to stop actions from the event system.

| improve this answer | |
2

If I understand well, you want to remove items published from certain publications from the publish transaction. I'm not sure if it would work (i've never tried it myself) but usually, you can build a custom resolver to deal with things like this.

In a custom resolver, you should be able to add or remove items from a publish transaction.

See some sample code here : http://www.tridiondeveloper.com/a-custom-resolver-in-practice

you could try something like this

foreach (ResolvedItem resolvedItem in originalResolveItemList)
{
     if (resolvedItem publication ID is in list of unpublishable publication ids)
     {
           resolvedItems.Remove(resolvedItem); // remove from items that will be published..
     }
}
| improve this answer | |
  • Hi @Herald, yes, that is the most obvious solution and we have it already implemented. However, we want to go one step further and to remove transactions altogether. This is because we have extensive publishing which is measured in 100K items daily (of which almost half are empty transactions). So not having them in queue at all would be the best solution. – Marko Milic Oct 5 '17 at 6:56

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.