We are using SDL Web 8.5 and DXA 2.0 Java. Our requirement is to publish an Excel file to a specific folder once a specific Component starts publishing. How can we achieve this using Event System?

Is the excel file managed in Tridion? If yes, then to have binaries deployed to a different folder than the default multimedia folder, you will need to use a method which takes a Structure Group as one of its parameters and the binary will end up in the corresponding file path.

If you can identify the specific component from within its template, then all you need to do is use the following method from within the CT, no need for an Event System:

RenderedItem.AddBinary(Component, StructureGroup)

The RenderedItem is available the following way engine.PublishingContext.RenderedItem

If you insist on an Event System, then from the top of my head, I would use the following approach.

  1. Have a dedicated CT which uses the previously described mechanism for publishing the binary. You can even have everything hardcoded.
  2. In a Publish Transaction Save event, check its state as In Progress and whether the specific Component is being published. Do note that the challenge here is identifying whether that component is published indirectly, which can happen.
  3. After detecting that the specific component is being published, publish the dedicated CT from within the ES code, which will in turn publish your binary
  • @Atlas We would like to also update the component field and it is known that Tridion does not allow to update the component while publishing it – Abdul Qadir Oct 16 at 9:57
  • The TOM.NET is indeed read only by default when used inside Templating. There is a setting however which can override this, but it is highly unrecommended because you defeat the purpose of security for example. – Atila Sos Oct 16 at 10:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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