问题
We would like to implement some functionality so that when for some reason an error occurs during publishing or resolving, and we skip over it using a try/catch block, but would still like to notify the user that something was skipped.
The SDL Tridion 2011 Publishing Queue can filter by status. One of these statuses is “Warning”. Is it possible to trigger a publish transaction to have a “Warning” status using the API in either template code or a custom resolver?
回答1:
I'm afraid this isn't possible, but the answers above might help you find an alternative solution to this.
回答2:
If all you need is a warning during the publishing (such that the Publish Transaction has status warning), then you will need to set PublishInstruction.MaximumNumberOfRenderFailures
to something greater than 0. As long as the number of Render errors is lower than the max you specified, the status of the Publish will be Warning.
If an error occurs outside rendering, then the instruction will show as Failed.
On the other hand, if you want to show a message in the GUI (in the MessageCenter) with the 'Warning' that something went wrong, then you will need a more complex architecture. Frank worked on this a while back. The idea (IIRC) is to have a GUI piece, e.g. an iframe polling a service that returns statuses for that user's Publish actions. An event system would produce these statuses by monitoring the PublishInstruction, and it would write them into some kind of storage (file, db, memory) that the service would then poll.
来源:https://stackoverflow.com/questions/9894802/raising-a-warning-status-during-sdl-tridion-2011-publishing