1

I want to make the publishing status as failed when a custom validation is not passed in SDL publish plugin. Anybody know which is the API method I need to use to make the publishing object failed or exit the publishing with failed status?

Thanks in advance.

  • You can simply throw an exception in your template code. The text you pass in the exception will be shown in the publishing queue as the reason. – Nuno Linhares May 9 at 18:59
  • Thank you so much .now i am able to make the publishing fail. I was just logging an event only not used throw exception. – user3165851 May 10 at 6:44
  • Cool - following StackExchange principles, can you maybe answer yourself with a small example of the code you used, then accept that answer? This will help others find solutions to the same problem. – Nuno Linhares May 11 at 7:04
1

Welcome to the community Roopesh. I am assuming that you are asking for content validation for SDL Tridion RTF Fields.

If this is related to UGC, you can refer the SDL live documentation.. You can handle the failure in your custom implementation.

I would firstly recommend that you think about your use case to avoid editors and publishers entering content that are not valid. By failing publishing, the users are forced to open the component, edit it and publish it again.

Ideally, you would not want to allow your users save the content, in the first place. For that, you can still refer to Nuno's blog. Using event system will help you throw custom error messages to the user. Using XML validation, you can implement it only for certain schemas.

Hope it helps!

P.S: If you would still like to fail publishing, you can still hook up to event system to use something like the below

EventSystem.Subscribe<PublishTransaction, SaveEventArgs>(YOURIMPLEMENTATATION, EventPhases.Initiated);

or include a TBB to perform the custom validation for you and throw an error. The error will be available when you click the failed publish transaction.

In any case, I strongly recommend you to validate the content on save since it provides a better user experience.

  • Thank you for the reply. Actually i am not validating the xml content. I have an HTML output in Tridion Docs. I have created a post process plugin(DLL) for getting metadata of a publication object from database while publishing the HTML output. If the metadata value is the expected one , then i need to make the HTML publishing object status as failed. – user3165851 May 10 at 6:11

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.